Skip to content

pascalmolin/sphinx-rstprog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sphinx-rstprog

Document simple programs with rst syntax and generate sphinx documentation.

Usage

Add and configure in conf.py:

extensions += ['sphinxcontrib.rstprog']

rstprog = [
  # ( extension, begin rstcomment, end rstcomment ),
  ('.gp', '/**', '**/' ),
  ('.c', '/**', '**/' ),
  ]

Installation

In this repository

pip3 install .

Tips

If you do not want all files to be processed by sphinx, use exclude_patterns to restrict the paths. Example, to process only files having extension .pub.c

exclude_patterns = ['*/*[!pub].c']

How does it work

This extensions registers a new source parser to sphinx (thanks to add_source_parser and add_source_suffix methods).

The parser adds to the usual rst parser a initial step which turns rst comment segments inside program into code segments inside rst. That is, a python file:

/** first litt. prog. comment **/
def foobar():
    pass
/** second comment **/
foobor()

is converted into the following rst:

first litt. prog. comment

.. code::

  def foobar():
    pass

second comment

.. code::

  foobor()

Future work

  • The parser could be improved (currently absolutely minimal and non robust).
  • Special markers in the comments could by used to change the sphinx directive used, or pass options.

About

document c and gp scripts in sphinx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages