sphinx-doc / sphinx-argparse

A Sphinx extension to automatically document argparse commands and options
https://sphinx-argparse.readthedocs.org/
MIT License
26 stars 24 forks source link

BUG: reST section headings do not render #31

Closed victorlin closed 2 months ago

victorlin commented 1 year ago

Description

reStructuredText headings do not render, and result in a CRITICAL build warning when run in nitpicky (-n) mode.

Steps to reproduce

  1. Create a file sample.py:

    import argparse
    
    def main():
        parser = argparse.ArgumentParser(
            description="""
    This is a section title
    -----------------------
    
    `I'm a link <http://www.google.com>`__
    """
        )
        parser.add_argument('cmd', help='execute a `command`')
        return parser
    
  2. Create a file index.rst:

    .. argparse::
       :filename: sample.py
       :func: main
  3. Create a file conf.py:

    extensions = [
        'sphinx.ext.autodoc',
        'sphinxarg.ext',
    ]
  4. Build it with nitpicky mode (sphinx-build . _build -n).

  5. Note this warning in the output:

    None:3: CRITICAL: Unexpected section title.
    
    This is a section title
    -----------------------

Built HTML shows the link but not the section title:

preview

ashb commented 2 months ago

I don't think this will really be fixable, it's tied in to how the sections get generated, sorry.

If someone can PR to fix this we'll review it, but right now this is a "sorry, wontfix"