sphinxref.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Sphinx reference
  2. Sphinx Tutorial - https://www.sphinx-doc.org/en/master/tutorial/index.html
  3. Sphinx tutorial - https://olgarithms.github.io/sphinx-tutorial/
  4. Documenting with Sphinx Tutorial -
  5. https://techwritingmatters.com/documenting-with-sphinx-tutorial-intro-overview
  6. Read the Docs - https://about.readthedocs.com/
  7. Sphinx Themes Gallery - https://sphinx-themes.readthedocs.io/en/latest/#themes
  8. Write the docs Sphinx themes - https://www.writethedocs.org/guide/tools/sphinx-themes/
  9. reStructuredText Markup Specification -
  10. https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#paragraphs
  11. Sphinx-RTD-Tutorial - https://sphinx-rtd-tutorial.readthedocs.io/en/latest/index.html
  12. $ python -m venv .venv
  13. $ source .venv/bin/activate
  14. (.venv)$ pip install sphinx
  15. (.venv)$ sphinx-build --version
  16. # creating the documentation layout
  17. (.venv)$ sphinx-quickstart docs
  18. This will present to you a series of questions required to create the basic directory
  19. and configuration layout for your project inside the docs directory. To proceed,
  20. answer each question as follows:
  21. > Separate source and build directories (y/n) [n]: Write "y" (without quotes)
  22. > Project name: Write "project_name" (without quotes) and press Enter
  23. > Author name(s): Write "First_name Last_name" (without quotes) and press Enter
  24. > Project release []: Write "0.1" (without quotes) and press Enter
  25. > Project language [en]: Leave it empty (the default, English) and press Enter
  26. After the last question, you will see the new docs directory with the following
  27. content.
  28. docs
  29. |____ build
  30. |____ make.bat
  31. |____ Makefile
  32. |____ source
  33. |____ conf.py
  34. |____ index.rst
  35. |____ _static
  36. |____ _templates
  37. The purpose of each of these files is:
  38. build/
  39. An empty directory (for now) that will hold the rendered documentation.
  40. make.bat and Makefile
  41. Convenience scripts to simplify some common Sphinx operations, such as
  42. rendering the content.
  43. source/conf.py
  44. A Python script holding the configuration of the Sphinx project. It contains
  45. the project name and release you specified to sphinx-quickstart, as well as
  46. some extra configuration keys.
  47. source/index.rst
  48. The root document of the project, which serves as welcome page and contains
  49. the root of the "table of contents tree" (or toctree).
  50. Thanks to this bootstrapping step, you already have everything needed to render
  51. the documentation as HTML for the first time. To do that, run this command:
  52. (.venv)$ sphinx-build -M html docs/sources/ docs/build/
  53. And finally, open docs/build/html/index.html in your browser.
  54. # C autodoc extension for sphinx
  55. (.venv)$ pip install sphinx-c-autodoc
  56. (.venv)$ pip install libclang
  57. edit docs/source/conf.py:
  58. extensions = [
  59. "sphinx_c_autodoc",
  60. "sphinx_c_autodoc.viewcode",
  61. ]
  62. c_autodoc_roots = ["../../src/fd1d"]
  63. edit docs/source/examples.rst:
  64. Examples
  65. ========
  66. .. autocfunction:: sources.c::pulse
  67. .. autocfunction:: sources.c::sinusoidal
  68. Reference:
  69. https://sphinx-c-autodoc.readthedocs.io/en/latest/index.html
  70. https://github.com/sighingnow/libclang/issues/27
  71. # example NumPy and Google style Python docstrings
  72. *args: variable length argument list
  73. **kwargs: arbitrary keyword arguments
  74. Reference:
  75. https://www.sphinx-doc.org/en/master/usage/extensions/example_numpy.html#example-numpy
  76. https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html#example-google
  77. # linking to a source code file
  78. .. literalinclude:: program.py
  79. .. literalinclude:: program.c
  80. :language: c
  81. :emphasize-lines: 12,15-18
  82. :linenos:
  83. .. literalinclude:: program.py
  84. :encoding: latin-1
  85. .. literalinclude:: program.py
  86. :pyobject: Timer.start # start() method in the Timer class
  87. .. literalinclude:: program.py
  88. :lines: 1,3,5-10,20- # include the lines 1, 3, 5 to 10 and lines 20 till end
  89. .. literalinclude:: program.py
  90. :diff: program.py.orig # shows the diff between program.py and program.py.orig