Problem:
Sphinx does not display documented code -only table of contents. I have isolated this down to Sphinx not generating the *.rst files for each documented *.py file when calling sphinx-apidoc.
Note:
I am using vscode with autodoc, the autodoc format is set to sphinx in the vscode settings file.
My project tree:
.
└── MNF
├── classes
│ ├── file_parser.py
│ └── README.txt
├── configs
│ ├── datasets.json
│ └── README.txt
├── data_in
│ └── README.txt
├── data_out
│ └── README.txt
├── LICENSE
├── models
│ └── README.txt
├── notebooks
│ ├── eda.ipynb
│ └── README.txt
├── packages.microsoft.gpg
├── papers
│ ├── conda-cheatsheet.pdf
│ ├── dejuan2013.pdf
│ ├── Git-Cheatsheet.pdf
│ └── READE.txt
├── plots
│ └── README.txt
├── __pycache__
│ └── file_parser.cpython-39.pyc
├── README.md
├── src
│ └── README.txt
├── test_branch.txt
├── test_main.txt
├── tests
│ └── README.txt
└── utilities
└── README.txt
Code of interest:
class FileParser:
"""File parser
"""
def __init__(self, root_path="../data_in/"):
"""
:param root_path: root path to search isHiddenWithinTree, defaults to "../data_in/"
:type root_path: str, optional
"""
self.root_path = root_path
def get_root_path(self):
"""Basic getter
:return: root path
:rtype: string
"""
return self.root_path
Steps part 1:
- mkdir docs
- cd docs
- sphinx-quickstart (seperatre source file, autodoc extention added)
modify conf.py:
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
to
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
Change index.rst to include modules:
===============================
.. toctree::
:maxdepth: 2
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Steps part 2:
In docs dir
- run sphinx-apidoc -o source/ ..
- make html
New docs tree
.
├── docs
│ ├── build
│ │ ├── doctrees
│ │ │ ├── environment.pickle
│ │ │ ├── index.doctree
│ │ │ └── modules.doctree
│ │ └── html
│ │ ├── genindex.html
│ │ ├── index.html
│ │ ├── modules.html
│ │ ├── objects.inv
│ │ ├── search.html
│ │ ├── searchindex.js
│ │ ├── _sources
│ │ │ ├── index.rst.txt
│ │ │ └── modules.rst.txt
│ │ └── _static
│ │ ├── ajax-loader.gif
│ │ ├── alabaster.css
│ │ ├── basic.css
│ │ ├── comment-bright.png
│ │ ├── comment-close.png
│ │ ├── comment.png
│ │ ├── custom.css
│ │ ├── doctools.js
│ │ ├── down.png
│ │ ├── down-pressed.png
│ │ ├── file.png
│ │ ├── jquery-3.2.1.js
│ │ ├── jquery.js
│ │ ├── minus.png
│ │ ├── plus.png
│ │ ├── pygments.css
│ │ ├── searchtools.js
│ │ ├── underscore-1.3.1.js
│ │ ├── underscore.js
│ │ ├── up.png
│ │ ├── up-pressed.png
│ │ └── websupport.js
modules.rst file:
git_mnf
=======
.. toctree::
:maxdepth: 4
Issue 1:
No file_parser.rst was generated.
Issue 2:
index.html page doesn't show any documentation
Help: I am at a lose with this one. Any ideas why my documentation for FileParse.py does not show?
Versions:
- Python 3.9.2
- sphinx 1.6.7
- vscode 1.54.3
- system: mac os
- browser: firefox