Skip to content

Commit

Permalink
chore: Add repository rst files in the sphinx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Mar 21, 2024
1 parent 663feed commit 05416f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,36 @@ def update_settings_module(service='lms'):
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module


def find_rst_files(directory):
rst_files = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.rst'):
rst_files.append(os.path.join(root, file))
return rst_files


def generate_toctree(custom_toctree_dir):
rst_files = find_rst_files(".")
toctree = "\n".join([" " + file for file in rst_files])
with open(custom_toctree_dir, 'w') as custom_docs:
custom_docs.write("\n..\n\tAutomatically Generated Toctree. See `generate_toctree` \
method in docs/conf.py.\nDo not change the contents of this file manually\n\n")
custom_docs.write(".. toctree::\n")
custom_docs.write(" :glob:\n")
custom_docs.write(toctree)


def on_init(app): # lint-amnesty, pylint: disable=redefined-outer-name, unused-argument
"""
Run sphinx-apidoc after Sphinx initialization.
Read the Docs won't run tox or custom shell commands, so we need this to
avoid checking in the generated reStructuredText files.
"""

generate_toctree('custom_toctree.rst')

docs_path = root / 'docs'
apidoc_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ locations.
.. _Open edX Development space: https://openedx.atlassian.net/wiki/spaces/COMM/overview
.. _Open edX ReadTheDocs: http://docs.edx.org/

.. include:: custom_toctree.rst

.. toctree::
:maxdepth: 1

Expand Down

0 comments on commit 05416f6

Please sign in to comment.