Thread: [Docstring-checkins] CVS: dps/dps/transforms frontmatter.py,1.4,1.5
Status: Pre-Alpha
Brought to you by:
goodger
From: David G. <go...@us...> - 2002-02-22 02:08:37
|
Update of /cvsroot/docstring/dps/dps/transforms In directory usw-pr-cvs1:/tmp/cvs-serv32681/dps/dps/transforms Modified Files: frontmatter.py Log Message: Updated for abstract; untabified. Index: frontmatter.py =================================================================== RCS file: /cvsroot/docstring/dps/dps/transforms/frontmatter.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** frontmatter.py 12 Feb 2002 02:17:56 -0000 1.4 --- frontmatter.py 22 Feb 2002 02:08:34 -0000 1.5 *************** *** 28,105 **** """ ! In reStructuredText_, there is no way to specify a document title ! and subtitle explicitly. Instead, we can supply the document title ! (and possibly the subtitle as well) implicitly, and use this ! two-step transform to "raise" or "promote" the title(s) (and their ! corresponding section contents) to the document level. ! 1. If the document contains a single top-level section as its ! first non-comment element, the top-level section's title ! becomes the document's title, and the top-level section's ! contents become the document's immediate contents. The lone ! top-level section header must be the first non-comment element ! in the document. ! For example, take this input text:: ! ================= ! Top-Level Title ! ================= ! A paragraph. ! Once parsed, it looks like this:: ! <document> ! <section name="top-level title"> ! <title> ! Top-Level Title ! <paragraph> ! A paragraph. ! After running the DocTitle transform, we have:: ! <document name="top-level title"> ! <title> ! Top-Level Title ! <paragraph> ! A paragraph. ! 2. If step 1 successfully determines the document title, we ! continue by checking for a subtitle. ! If the lone top-level section itself contains a single ! second-level section as its first non-comment element, that ! section's title is promoted to the document's subtitle, and ! that section's contents become the document's immediate ! contents. Given this input text:: ! ================= ! Top-Level Title ! ================= ! Second-Level Title ! ~~~~~~~~~~~~~~~~~~ ! A paragraph. ! After parsing and running the Section Promotion transform, the ! result is:: ! <document name="top-level title"> ! <title> ! Top-Level Title ! <subtitle name="second-level title"> ! Second-Level Title ! <paragraph> ! A paragraph. ! (Note that the implicit hyperlink target generated by the ! "Second-Level Title" is preserved on the "subtitle" element ! itself.) ! Any comment elements occurring before the document title or ! subtitle are accumulated and inserted as the first body elements ! after the title(s). """ --- 28,105 ---- """ ! In reStructuredText_, there is no way to specify a document title ! and subtitle explicitly. Instead, we can supply the document title ! (and possibly the subtitle as well) implicitly, and use this ! two-step transform to "raise" or "promote" the title(s) (and their ! corresponding section contents) to the document level. ! 1. If the document contains a single top-level section as its ! first non-comment element, the top-level section's title ! becomes the document's title, and the top-level section's ! contents become the document's immediate contents. The lone ! top-level section header must be the first non-comment element ! in the document. ! For example, take this input text:: ! ================= ! Top-Level Title ! ================= ! A paragraph. ! Once parsed, it looks like this:: ! <document> ! <section name="top-level title"> ! <title> ! Top-Level Title ! <paragraph> ! A paragraph. ! After running the DocTitle transform, we have:: ! <document name="top-level title"> ! <title> ! Top-Level Title ! <paragraph> ! A paragraph. ! 2. If step 1 successfully determines the document title, we ! continue by checking for a subtitle. ! If the lone top-level section itself contains a single ! second-level section as its first non-comment element, that ! section's title is promoted to the document's subtitle, and ! that section's contents become the document's immediate ! contents. Given this input text:: ! ================= ! Top-Level Title ! ================= ! Second-Level Title ! ~~~~~~~~~~~~~~~~~~ ! A paragraph. ! After parsing and running the Section Promotion transform, the ! result is:: ! <document name="top-level title"> ! <title> ! Top-Level Title ! <subtitle name="second-level title"> ! Second-Level Title ! <paragraph> ! A paragraph. ! (Note that the implicit hyperlink target generated by the ! "Second-Level Title" is preserved on the "subtitle" element ! itself.) ! Any comment elements occurring before the document title or ! subtitle are accumulated and inserted as the first body elements ! after the title(s). """ *************** *** 157,225 **** """ ! This transform is specific to the reStructuredText_ markup syntax; ! see "Bibliographic Fields" in the `reStructuredText Markup ! Specification`_ for a high-level description. This transform ! should be run *after* the `DocTitle` transform. ! Given a field list as the first non-comment element after the ! document title and subtitle (if present), registered bibliographic ! field names are transformed to the corresponding DTD elements, ! becoming child elements of the "docinfo" element. ! For example, given this document fragment after parsing:: ! <document> ! <title> ! Document Title ! <field_list> ! <field> ! <field_name> ! Author ! <field_body> ! <paragraph> ! Kilgore Trout ! <field> ! <field_name> ! Status ! <field_body> ! <paragraph> ! $RCSfile$ ! ... ! After running the bibliographic field list transform, the ! resulting document tree would look like this:: ! <document> ! <title> ! Document Title ! <docinfo> ! <author> ! Kilgore Trout ! <status> ! frontmatter.py ! ... ! The "Status" field contained an expanded RCS keyword, which is ! normally (but optionally) cleaned up by the transform. The sole ! contents of the field body must be a paragraph containing an ! expanded RCS keyword of the form "$keyword: expansion text $". Any ! RCS keyword can be processed in any bibliographic field. The ! dollar signs and leading RCS keyword name are removed. Extra ! processing is done for the following RCS keywords: ! - "RCSfile" expands to the name of the file in the RCS or CVS ! repository, which is the name of the source file with a ",v" ! suffix appended. The transform will remove the ",v" suffix. ! - "Date" expands to the format "YYYY/MM/DD hh:mm:ss" (in the UTC ! time zone). The RCS Keywords transform will extract just the ! date itself and transform it to an ISO 8601 format date, as in ! "2000-12-31". ! (Since the source file for this text is itself stored under CVS, ! we can't show an example of the "Date" RCS keyword because we ! can't prevent any RCS keywords used in this explanation from ! being expanded. Only the "RCSfile" keyword is stable; its ! expansion text changes only if the file name changes.) """ --- 157,226 ---- """ ! This transform is specific to the reStructuredText_ markup syntax; ! see "Bibliographic Fields" in the `reStructuredText Markup ! Specification`_ for a high-level description. This transform ! should be run *after* the `DocTitle` transform. ! Given a field list as the first non-comment element after the ! document title and subtitle (if present), registered bibliographic ! field names are transformed to the corresponding DTD elements, ! becoming child elements of the "docinfo" element (except for the ! "abstract" element, which comes after "docinfo"). ! For example, given this document fragment after parsing:: ! <document> ! <title> ! Document Title ! <field_list> ! <field> ! <field_name> ! Author ! <field_body> ! <paragraph> ! Kilgore Trout ! <field> ! <field_name> ! Status ! <field_body> ! <paragraph> ! $RCSfile$ ! ... ! After running the bibliographic field list transform, the ! resulting document tree would look like this:: ! <document> ! <title> ! Document Title ! <docinfo> ! <author> ! Kilgore Trout ! <status> ! frontmatter.py ! ... ! The "Status" field contained an expanded RCS keyword, which is ! normally (but optionally) cleaned up by the transform. The sole ! contents of the field body must be a paragraph containing an ! expanded RCS keyword of the form "$keyword: expansion text $". Any ! RCS keyword can be processed in any bibliographic field. The ! dollar signs and leading RCS keyword name are removed. Extra ! processing is done for the following RCS keywords: ! - "RCSfile" expands to the name of the file in the RCS or CVS ! repository, which is the name of the source file with a ",v" ! suffix appended. The transform will remove the ",v" suffix. ! - "Date" expands to the format "YYYY/MM/DD hh:mm:ss" (in the UTC ! time zone). The RCS Keywords transform will extract just the ! date itself and transform it to an ISO 8601 format date, as in ! "2000-12-31". ! (Since the source file for this text is itself stored under CVS, ! we can't show an example of the "Date" RCS keyword because we ! can't prevent any RCS keywords used in this explanation from ! being expanded. Only the "RCSfile" keyword is stable; its ! expansion text changes only if the file name changes.) """ *************** *** 276,288 **** remainder.append(field) continue if abstract: ! docinfo.append(abstract) ! if len(docinfo) == 0: ! return [], field_list if remainder: field_list[:] = remainder else: field_list = None ! return [docinfo], field_list def check_empty_biblio_field(self, field, name): --- 277,290 ---- remainder.append(field) continue + nodelist = [] + if len(docinfo) != 0: + nodelist.append(docinfo) if abstract: ! nodelist.append(abstract) if remainder: field_list[:] = remainder else: field_list = None ! return nodelist, field_list def check_empty_biblio_field(self, field, name): |