### Installing Sphinx Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Installs the Sphinx documentation generator, a Python package built on top of docutils, using pip. ```bash python -m pip install sphinx ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Initialize and Build Sphinx Documentation Project Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt Instructions for installing Sphinx, creating a new documentation project using 'sphinx-quickstart', and building the documentation into various formats like HTML, ePub, man pages, and LaTeX. ```bash # Install Sphinx python -m pip install sphinx # Create new documentation project sphinx-quickstart docs # Project structure created: # docs/ # ├── index.rst # ├── Makefile # ├── make.bat # ├── conf.py # └── _build/ # Build the documentation cd docs make html # Generate HTML website make singlehtml # Generate single-page HTML make epub # Generate ePub ebook make man # Generate man pages make latex # Generate LaTeX source make text # Generate plain text # Output appears in _build/ directory ``` -------------------------------- ### Installing Pandoc on macOS Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Installs the Pandoc universal document converter on macOS using the Homebrew package manager. ```bash brew install pandoc ``` -------------------------------- ### Basic docutils Conversion Examples Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Demonstrates how to use docutils command-line tools to convert reStructuredText files to different output formats. The output can be piped to a file. ```bash rst2html5 mydoc.rst > mydoc.html ``` -------------------------------- ### Minimal Custom HTML Writer with Docutils Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst A Python example demonstrating how to create a minimal custom HTML writer and translator by subclassing existing classes from the 'docutils' package. This serves as a starting point for modifying the HTML output generated from reStructuredText. ```python """Minimal writer/translator for customizing docutils output""" from docutils.writers import html5_polyglot from docutils.core import publish_string class MyCustomHTMLTranslator(html5_polyglot.HTMLTranslator): pass class MyCustomHTMLWriter(html5_polyglot.Writer): def __init__( self ): html5_polyglot.Writer.__init__(self) self.translator_class = MyCustomHTMLTranslator if __name__ == '__main__': html_output = publish_string(source='Put reStructured text here.', writer=MyCustomHTMLWriter()) print(html_output) ``` -------------------------------- ### Install docutils using pip Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Shows the command to install the 'docutils' Python package using pip. Docutils is a core tool for parsing, formatting, and outputting reStructuredText documents to various formats like HTML. ```bash python -m pip install docutils ``` -------------------------------- ### Basic reStructuredText Document Structure Example Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt An example of a simple reStructuredText (RST) document showcasing document title, subtitle, headers, subheadings, and bullet points. ```rst ================= My Project Readme ================= ------------------------- Clever subtitle goes here ------------------------- Introduction ============ This is an example reStructuredText document that starts at the very top with a title and a sub-title. There is one primary header, Introduction. There is one example subheading below. The document is just plain text so it is easily readable even before being converted to HTML, man page, PDF or other formats. Subheading ---------- The basic syntax is not that different from Markdown, but it also has many more powerful features that Markdown doesn't have. We aren't taking advantage of those yet though. - Bullet points - Are intuitive - And simple too ``` -------------------------------- ### Convert Documents Using Pandoc Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt Demonstrates using the Pandoc command-line tool for converting documents between various formats, including RST, HTML, DOCX, PDF, EPUB, and PPTX. Installation instructions for different operating systems are also provided. ```bash # Install Pandoc from https://pandoc.org/installing.html # - Windows: Download installer from GitHub releases # - Mac: brew install pandoc # - Linux: Download .deb or .tar.gz from GitHub releases # Convert RST to various formats pandoc input.rst -o output.html pandoc input.rst -o output.docx pandoc input.rst -o output.pdf pandoc input.rst -o output.epub pandoc input.rst -o output.pptx # Convert from other formats to RST pandoc input.md -o output.rst pandoc input.docx -o output.rst pandoc input.html -o output.rst # Example with options pandoc input.rst -o output.pdf --pdf-engine=xelatex --toc ``` -------------------------------- ### Convert RST to HTML and Other Formats using docutils Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt Demonstrates how to install docutils and convert reStructuredText (RST) files into HTML5, man pages, XML, and LaTeX formats using command-line tools. ```bash # Install docutils python -m pip install docutils # Convert RST to HTML5 rst2html5 mydoc.rst > mydoc.html # Convert RST to other formats rst2man mydoc.rst > mydoc.1 rst2xml mydoc.rst > mydoc.xml rst2latex mydoc.rst > mydoc.tex ``` -------------------------------- ### Restructured Text toctree Directive Example Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst An example of the 'toctree' directive used in reStructuredText to create a master landing page that links to sub-documents. It specifies the paths to other .rst files to be included in the table of contents. ```rst .. toctree:: whatsnew/index.rst tutorial/index.rst faq/index.rst glossary.rst about.rst bugs.rst copyright.rst license.rst ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### RST Syntax Examples for Documentation Elements Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt This snippet demonstrates various reStructuredText (RST) syntax elements used for structuring and formatting documentation. It covers titles, text styling, lists, comments, images, preformatted text, code blocks, links, footnotes, and tables. No external dependencies are required to interpret this markup. ```rst """"""""""""""" Document Title """"""""""""""" ........... Subtitle ........... .. contents:: Overview :depth: 3 =================== Section 1 =================== Text can be *italicized* or **bolded** as well as ``monospaced``. You can \*escape certain\* special characters. ---------------------- Subsection 1 (Level 2) ---------------------- Some section 2 text Sub-subsection 1 (level 3) -------------------------- Some more text. -------- Comments -------- .. This is a comment Special notes that are not shown but might come out as HTML comments ------ Images ------ .. image:: screenshots/file.png :height: 100 :width: 200 :alt: alternate text You can inline an image or other directive with the |customsub| command. .. |customsub| image:: image/image.png :alt: (missing image text) ----- Lists ----- - Bullet are made like this - Point levels must be consistent * Sub-bullets + Sub-sub-bullets - Lists Term Definition for term Term2 Definition for term 2 :List of Things: item1 - these are 'field lists' not bulleted lists item2 item 3 :Something: single item :Someitem: single item ----------------- Preformatted text ----------------- A code example prefix must always end with double colon like it's presenting something:: Anything indented is part of the preformatted block Until It gets back to Allll the way left Now we're out of the preformatted block. ------------ Code blocks ------------ .. code:: python import os print(help(os)) ----- Links ----- Web addresses by themselves will auto link, like this: https://www.devdungeon.com You can also inline custom links: `Google search engine `_ This is a simple link_ to Google with the link defined separately. .. _link: https://www.google.com This is a link to the `Python website`_. .. _Python website: http://www.python.org/ --------- Footnotes --------- Footnote Reference [1]_ .. [1] This is footnote number one that would go at the bottom of the document. Or autonumbered [#] .. [#] This automatically becomes second, based on the 1 already existing. ------ Tables ------ +--------+--------+--------+ | Time | Number | Value | +========+========+========+ | 12:00 | 42 | 2 | +--------+--------+--------+ | 23:00 | 23 | 4 | +--------+--------+--------+ ---------------------- Preserving line breaks ---------------------- | These lines will | break exactly | where we told them to. ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Custom Directive Registration and Usage (Python) Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt An example demonstrating how to create and register a custom directive in reStructuredText using the 'docutils' library. This allows for custom content processing and insertion into the document. It returns a raw HTML node with the processed content. ```python from docutils import nodes from docutils.parsers.rst import directives, Directive from docutils.core import publish_string from docutils.writers import html5_polyglot class MyCustomDirective(Directive): required_arguments = 1 optional_arguments = 0 final_argument_whitespace = True option_spec = {} has_content = True def run(self): self.assert_has_content() # Access arguments and options argument = self.arguments[0] content = '\n'.join(self.content) # Perform custom logic here processed_content = f"Custom processing: {argument}\n{content}" # Return a node to be inserted into the document return [nodes.raw('', processed_content, format='html')] ``` -------------------------------- ### Creating a New Sphinx Project Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Initializes a new Sphinx documentation project, creating a directory structure and configuration files. It prompts the user for project details. ```bash sphinx-quickstart docs ``` -------------------------------- ### Building Sphinx Projects with Make Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Commands to build Sphinx documentation into various formats using the generated Makefile. The output is typically placed in the \'_build\' directory. ```bash make html make singlehtml make epub make man make latex make text ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### HTML: rst2html5 Conversion Command Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Provides the command-line instruction for converting a reStructuredText file (sample.rst) into an HTML file (sample.html) using the rst2html5 tool. ```bash rst2html5 sample.rst > sample.html ``` -------------------------------- ### reStructuredText: Basic Document Structure and Headings Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Demonstrates the creation of document titles, subtitles, and section headings using different underline styles in reStructuredText. It also shows the use of the 'contents' directive for generating an overview. ```rst """"""""""""""""""" Document Title """""""""""""""""""" ........... Subtitle ........... .. contents:: Overview :depth: 3 =================== Section 1 =================== Text can be *italicized* or **bolded** as well as ``monospaced``. You can \*escape certain\* special characters. ---------------------- Subsection 1 (Level 2) ---------------------- Some section 2 text Sub-subsection 1 (level 3) -------------------------- Some more text. ========= Examples ========= -------- Comments -------- .. This is a comment Special notes that are not shown but might come out as HTML comments ------ Images ------ Add an image with: .. image:: screenshots/file.png :height: 100 :width: 200 :alt: alternate text You can inline an image or other directive with the |customsub| command. .. |customsub| image:: image/image.png :alt: (missing image text) ----- Lists ----- - Bullet are made like this - Point levels must be consistent * Sub-bullets + Sub-sub-bullets - Lists Term Definition for term Term2 Definition for term 2 :List of Things: item1 - these are 'field lists' not bulleted lists item2 item 3 :Something: single item :Someitem: single item ----------------- Preformatted text ----------------- A code example prefix must always end with double colon like it's presenting something:: Anything indented is part of the preformatted block Until It gets back to Allll the way left Now we're out of the preformatted block. ------------ Code blocks ------------ There are three equivalents: ``code``, ``sourcecode``, and ``code-block``. .. code:: python import os print(help(os)) .. sourcecode:: # Equivalent .. code-block:: # Equivalent ----- Links ----- Web addresses by themselves will auto link, like this: https://www.devdungeon.com You can also inline custom links: `Google search engine `_ This is a simple link_ to Google with the link defined separately. .. _link: https://www.google.com This is a link to the `Python website`_. .. _Python website: http://www.python.org/ This is a link back to `Section 1`_. You can link based off of the heading name within a document. --------- Footnotes --------- Footnote Reference [1]_ .. [1] This is footnote number one that would go at the bottom of the document. Or autonumbered [#] .. [#] This automatically becomes second, based on the 1 already existing. ----------------- Lines/Transitions ----------------- Any 4+ repeated characters with blank lines surrounding it becomes an hr line, like this. ==================================== ------ Tables ------ +--------+--------+--------+ | Time | Number | Value | +========+========+========+ | 12:00 | 42 | 2 | +--------+--------+--------+ | 23:00 | 23 | 4 | +--------+--------+--------+ ---------------------- Preserving line breaks ---------------------- Normally you can break the line in the middle of a paragraph and it will ignore the newline. If you want to preserve the newlines, use the ``|`` prefix on the lines. For example: | These lines will | break exactly | where we told them to. ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### reStructuredText: External and Internal Links Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Demonstrates various methods for creating links in reStructuredText, including auto-linking URLs, inline custom links, and defining links separately for reuse. It also shows how to create internal links to headings within the document. ```rst https://www.devdungeon.com `Google search engine `_ This is a simple link_ to Google with the link defined separately. .. _link: https://www.google.com This is a link to the `Python website`_. .. _Python website: http://www.python.org/ This is a link back to `Section 1`_. You can link based off of the heading name within a document. ``` -------------------------------- ### Untitled No description -------------------------------- ### reStructuredText: Code Block Directives Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Illustrates the usage of different reStructuredText directives for displaying code blocks: 'code', 'sourcecode', and 'code-block'. The 'code' directive can specify a language for syntax highlighting. ```rst .. code:: python import os print(help(os)) .. sourcecode:: # Equivalent .. code-block:: # Equivalent ``` -------------------------------- ### Script to Convert reStructuredText to HTML Body Fragment Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst This Python script demonstrates how to use the custom ``HTMLBodyWriter`` to process a reStructuredText file. It reads the content from the first command-line argument, publishes it using ``publish_parts`` with the custom writer, and then prints the stylesheet and body sections to standard output, creating an HTML fragment. ```python if __name__ == '__main__': # rst2html5body.py """ Take a filename from the first command-line argument, process it using the custom writer, and output the body section only to standard output. Example usage:: rst2html5body.py readme.rst > readme.html Then use that output as the content for your blog post. """ from docutils.core import publish_parts import sys # First argument provided on the command line is the RST file name with open(sys.argv[1]) as rst_file: rst_content = rst_file.read() # publish_parts() will return a dictionary with the different # parts of the document, like head, stylesheet, body, already # processed and turned in to HTML, just separated for us. # There are other ``publish_*`` options like publish_cmdline, # publish_file, publish_string, and more. # If you want the final full standalone HTML document with all the # boilerplate,use ``publish_string()`` instead. output_document_parts = publish_parts(source=rst_content, writer=HTMLBodyWriter()) # >>> output_parts.keys() # List all of the parts available # ['whole', 'encoding', 'version', 'head_prefix', 'head', 'stylesheet', # 'body_prefix', 'body_pre_docinfo', 'docinfo', 'body', 'body_suffix', # 'title', 'subtitle', 'header', 'footer', 'meta', 'fragment', # 'html_prolog', 'html_head', 'html_title', 'html_subtitle', 'html_body'] print(output_document_parts['stylesheet']) print(output_document_parts['body']) ``` -------------------------------- ### reStructuredText: Footnote Syntax Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Shows how to implement footnotes in reStructuredText using reference-style and auto-numbered footnotes. These are typically rendered at the bottom of the document. ```rst Footnote Reference [1]_ .. [1] This is footnote number one that would go at the bottom of the document. Or autonumbered [#] .. [#] This automatically becomes second, based on the 1 already existing. ``` -------------------------------- ### Minimal Custom Directive Skeleton in Python Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst This Python snippet illustrates the minimal structure required to create a custom reStructuredText directive. It involves defining a class that inherits from 'docutils.parsers.rst.Directive' and registering it using 'directives.register'. The 'run' method is a placeholder for directive logic. ```python class MyCustomDirective(Directive) run(): print('it ran!') return(my custom node? a text node? a code bloc node? an image? etc) process without outputting anything? directives.register('shortcutname', MyCustomDirective) ``` -------------------------------- ### Untitled No description -------------------------------- ### Sphinx toctree for Multi-Document Linking (RST) Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt This reStructuredText (RST) snippet demonstrates the Sphinx `toctree` directive. It is used to create a table of contents that links to multiple separate documentation files, organizing a project into a cohesive structure. This is a core feature for managing large documentation sets. ```rst .. toctree:: whatsnew/index.rst tutorial/index.rst faq/index.rst glossary.rst about.rst bugs.rst copyright.rst license.rst ``` -------------------------------- ### Sphinx:toctree Directive for Multi-File Documents Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Introduces the Sphinx 'toctree' directive, which is used to link multiple reStructuredText files together and embed a table of contents from another page. This facilitates the organization of large documentation projects. ```rst Sphinx has a special directive for building linking pages together and embedding a table of contents from another page. The ``toctree`` directive will essentially import the headings/table of contents ``` -------------------------------- ### Custom HTML Writer for Docutils (Python) Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt This Python code defines a minimal custom HTML writer and translator for the `docutils` library. It extends the default `html5_polyglot` writer to allow for customization of the generated HTML output. The `publish_string` function from `docutils.core` is used to process reStructuredText content with the custom writer. ```python """Minimal writer/translator for customizing docutils output""" from docutils.writers import html5_polyglot from docutils.core import publish_string class MyCustomHTMLTranslator(html5_polyglot.HTMLTranslator): pass class MyCustomHTMLWriter(html5_polyglot.Writer): def __init__(self): html5_polyglot.Writer.__init__(self) self.translator_class = MyCustomHTMLTranslator if __name__ == '__main__': html_output = publish_string( source='Put reStructured text here.', writer=MyCustomHTMLWriter() ) print(html_output) ``` -------------------------------- ### Custom HTML Body Writer for CMS Integration (Python) Source: https://context7.com/devdungeon/restructuredtext-documentation-reference/llms.txt A custom docutils writer that converts reStructuredText to HTML5, outputting only the HTML body for embedding within CMS platforms. It requires the 'docutils' library. The output is the HTML body of the converted RST content. ```python """ A custom docutils writer that will convert reStructuredText (RST) to html5, but slightly modified from the html5_polyglot writer. The goal is to output only the HTML body with the intention of embedding it inside a larger HTML document using a content management system (CMS) like Drupal, Wordpress, or Django. """ from docutils.writers import html5_polyglot from docutils import nodes from docutils.core import publish_parts import sys class HTMLBodyTranslator(html5_polyglot.HTMLTranslator): """ Contains all the logic on how to wrap various nodes with HTML. For each node type, you can write a ``visit_*`` and ``depart_*`` method. """ def visit_title(self, node): # Modified code to lower heading levels by one check_id = 0 close_tag = '

\n' if isinstance(node.parent, nodes.topic): self.body.append( self.starttag(node, 'p', '', CLASS='topic-title first')) elif isinstance(node.parent, nodes.sidebar): self.body.append( self.starttag(node, 'p', '', CLASS='sidebar-title')) elif isinstance(node.parent, nodes.Admonition): self.body.append( self.starttag(node, 'p', '', CLASS='admonition-title')) elif isinstance(node.parent, nodes.table): self.body.append( self.starttag(node, 'caption', '')) close_tag = '\n' elif isinstance(node.parent, nodes.document): self.body.append(self.starttag(node, 'h1', '', CLASS='title')) close_tag = '\n' self.in_document_title = len(self.body) else: assert isinstance(node.parent, nodes.section) h_level = self.section_level + self.initial_header_level atts = {} if ( len(node.parent) >= 2 and isinstance(node.parent[1], nodes.subtitle)): atts['CLASS'] = 'with-subtitle' self.body.append( self.starttag(node, 'h%s' % h_level, '', **atts)) atts = {} if node.hasattr('refid'): atts['class'] = 'toc-backref' atts['href'] = '#' + node['refid'] if atts: self.body.append(self.starttag({}, 'a', '', **atts)) close_tag = '\n' % (h_level) else: close_tag = '\n' % (h_level) self.context.append(close_tag) def should_be_compact_paragraph(self, node): if(isinstance(node.parent, nodes.block_quote)): return 0 class HTMLBodyWriter(html5_polyglot.Writer): """ A ``docutils`` writer that will output HTML intended to be used within a larger existing HTML document, like within a content management system blog post. """ def __init__(self): self.parts = {} self.translator_class = HTMLBodyTranslator if __name__ == '__main__': """ Example usage: python rst2html5body.py readme.rst > readme.html """ # First argument provided on the command line is the RST file name with open(sys.argv[1]) as rst_file: rst_content = rst_file.read() # publish_parts() returns a dictionary with different parts # of the document like head, stylesheet, body, etc. output_document_parts = publish_parts( source=rst_content, writer=HTMLBodyWriter() ) # Available parts: 'whole', 'encoding', 'version', 'head_prefix', # 'head', 'stylesheet', 'body_prefix', 'body_pre_docinfo', 'docinfo', # 'body', 'body_suffix', 'title', 'subtitle', 'header', 'footer', # 'meta', 'fragment', 'html_prolog', 'html_head', 'html_title', # 'html_subtitle', 'html_body' print(output_document_parts['stylesheet']) print(output_document_parts['body']) ``` -------------------------------- ### Custom HTML5 Polyglot Writer for Docutils Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst This Python class extends the ``html5_polyglot.Writer`` from ``docutils`` to create a custom HTML writer. It specifically overrides the ``translator_class`` to use ``HTMLBodyTranslator``, allowing for tailored HTML output suitable for embedding within existing documents. ```python class HTMLBodyWriter(html5_polyglot.Writer): """ A ``docutils`` writer that will output HTML intended to be used within a larger existing HTML document, like within a content management system blog post. Writer that inherits from ``distutils.writers.html5_polyglot.Writer``. but overrides the ``translator_class`` which makes a few tweaks like lowering the heading levels by one. """ def __init__(self): self.parts = {} self.translator_class = HTMLBodyTranslator ``` -------------------------------- ### Base Directive Class in Python Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst Illustrates the base Directive class for reStructuredText directives, defined within the docutils library. This class serves as the foundation for all custom and built-in directives. ```python # Defined in docutils.parsers.rst.__init__.py class Directive(object): pass ``` -------------------------------- ### Custom HTML Writer Implementation (Python) Source: https://github.com/devdungeon/restructuredtext-documentation-reference/blob/master/README.rst This Python code defines a custom docutils writer and translator. It inherits from html5_polyglot and modifies the `visit_title` method to adjust how titles are rendered, typically lowering the heading level by one for CMS integration. It also provides a detailed class docstring explaining its purpose and usage. ```python from docutils.writers import html5_polyglot from docutils import nodes import os class HTMLBodyTranslator(html5_polyglot.HTMLTranslator): """ Contains all the logic on how to wrap various nodes with HTML. For each node type, you can write a ``visit_*`` and ``depart_*`` method. Copy the existing method from ``docutils.writers.html5_polyglot.HTMLTranslator`` if there is one, and modify it from there. Get list of all node types:: >>> import docutils.nodes >>> docutils.nodes.node_class_names >>> help(docutils.nodes) node_class_names: Text abbreviation acronym address admonition attention attribution author authors block_quote bullet_list caption caution citation citation_reference classifier colspec comment compound contact container copyright danger date decoration definition definition_list definition_list_item description docinfo doctest_block document emphasis entry enumerated_list error field field_body field_list field_name figure footer footnote footnote_reference generated header hint image important inline label legend line line_block list_item literal literal_block math math_block note option option_argument option_group option_list option_list_item option_string organization paragraph pending problematic raw reference revision row rubric section sidebar status strong subscript substitution_definition substitution_reference subtitle superscript system_message table tbody term tgroup thead tip title title_reference topic transition version warning """ def visit_title(self, node): # Modifed code, copied from parent class check_id = 0 # TODO: is this a bool (False) or a counter? close_tag = '

\n' if isinstance(node.parent, nodes.topic): self.body.append( self.starttag(node, 'p', '', CLASS='topic-title first')) elif isinstance(node.parent, nodes.sidebar): self.body.append( self.starttag(node, 'p', '', CLASS='sidebar-title')) elif isinstance(node.parent, nodes.Admonition): self.body.append( self.starttag(node, 'p', '', CLASS='admonition-title')) elif isinstance(node.parent, nodes.table): self.body.append( self.starttag(node, 'caption', '')) close_tag = '\n' elif isinstance(node.parent, nodes.document): self.body.append(self.starttag(node, 'h1', '', CLASS='title')) close_tag = '\n' self.in_document_title = len(self.body) else: assert isinstance(node.parent, nodes.section) h_level = self.section_level + self.initial_header_level# - 1 atts = {} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.