Skip to content

Commit 8299a04

Browse files
Merge pull request #23 from semiotic-ai/codeblock-warnings
codeblocks and warnings
2 parents bd8492a + dc5fa2e commit 8299a04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+728
-406
lines changed

graphdoc/docs/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

graphdoc/docs/conf.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"sphinx.ext.autodoc",
2121
"sphinx.ext.napoleon",
2222
"sphinx.ext.viewcode",
23+
"sphinx.ext.intersphinx", # Add intersphinx for better cross-referencing
2324
]
2425

2526
# Add Napoleon settings for Google-style docstrings
@@ -53,3 +54,29 @@
5354
import sys
5455

5556
sys.path.insert(0, os.path.abspath(".."))
57+
58+
# Configure autodoc settings to handle duplicate signatures
59+
autodoc_default_options = {
60+
"members": True,
61+
"undoc-members": True,
62+
"show-inheritance": True,
63+
"member-order": "bysource",
64+
}
65+
66+
# Configure intersphinx mapping for external projects
67+
intersphinx_mapping = {
68+
"python": ("https://docs.python.org/3", None),
69+
}
70+
71+
# Ensure that objects are documented only once at their canonical location
72+
canonical_module_mapping = {}
73+
74+
75+
# Configure nitpicky mode to be less strict
76+
nitpicky = False
77+
78+
79+
def setup(app):
80+
# Create static directory if it doesn't exist to avoid the warning
81+
if not os.path.exists(os.path.join(os.path.dirname(__file__), "_static")):
82+
os.makedirs(os.path.join(os.path.dirname(__file__), "_static"))

graphdoc/docs/generate_docs.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env python
2+
"""
3+
Script to automatically generate Sphinx documentation RST files.
4+
Run this script before building the documentation to ensure all RST files are up-to-date.
5+
"""
6+
import os
7+
import shutil
8+
import subprocess
9+
import sys
10+
11+
12+
def main():
13+
# Get the directory where this script is located
14+
docs_dir = os.path.dirname(os.path.abspath(__file__))
15+
16+
# The path to the module we want to document
17+
module_dir = os.path.abspath(os.path.join(docs_dir, ".."))
18+
19+
# Where to output the rst files
20+
output_dir = docs_dir
21+
22+
# Clean up existing RST files except for special ones
23+
preserve_files = ["index.rst", "conf.py", "generate_docs.py", "links.rst"]
24+
for filename in os.listdir(output_dir):
25+
filepath = os.path.join(output_dir, filename)
26+
if (
27+
filename.endswith(".rst")
28+
and filename not in preserve_files
29+
and os.path.isfile(filepath)
30+
):
31+
print(f"Removing {filepath}")
32+
os.unlink(filepath)
33+
34+
# Run sphinx-apidoc
35+
subprocess.run(
36+
[
37+
"sphinx-apidoc",
38+
"-f", # Force overwriting of existing files
39+
"-e", # Put module documentation before submodule documentation
40+
"-M", # Put module documentation before member documentation
41+
"-o",
42+
output_dir, # Output directory
43+
module_dir, # Module directory
44+
"setup.py", # Exclude these files/patterns
45+
"*tests*",
46+
"*venv*",
47+
"*docs*",
48+
]
49+
)
50+
51+
# Add custom content to the module RST files
52+
customize_rst_files(output_dir)
53+
54+
print("\nRST files have been generated successfully!")
55+
print("You can now build the documentation with: cd docs && make html")
56+
57+
58+
def customize_rst_files(output_dir):
59+
"""Add custom content to the RST files."""
60+
# Example: Add a note about auto-generation to each RST file
61+
for filename in os.listdir(output_dir):
62+
if filename.endswith(".rst") and filename != "index.rst":
63+
filepath = os.path.join(output_dir, filename)
64+
with open(filepath, "r") as f:
65+
content = f.read()
66+
67+
# Add noindex to submodules to prevent duplicates
68+
content = content.replace(
69+
":show-inheritance:", ":show-inheritance:\n :noindex:"
70+
)
71+
72+
with open(filepath, "w") as f:
73+
f.write(content)
74+
75+
# Create or update index.rst if it doesn't exist
76+
index_path = os.path.join(output_dir, "index.rst")
77+
if not os.path.exists(index_path):
78+
with open(index_path, "w") as f:
79+
f.write(
80+
""".. GraphDoc documentation master file
81+
82+
Welcome to GraphDoc's documentation
83+
==================================
84+
85+
.. toctree::
86+
:maxdepth: 2
87+
:caption: Contents:
88+
89+
modules
90+
91+
Indices and tables
92+
==================
93+
94+
* :ref:`genindex`
95+
* :ref:`modindex`
96+
* :ref:`search`
97+
"""
98+
)
99+
100+
101+
if __name__ == "__main__":
102+
main()

graphdoc/docs/graphdoc.config.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.config module
2+
======================
3+
4+
.. automodule:: graphdoc.config
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.data.dspy\_data.dspy\_data\_helper module
2+
==================================================
3+
4+
.. automodule:: graphdoc.data.dspy_data.dspy_data_helper
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.data.dspy\_data.generation\_data\_helper module
2+
========================================================
3+
4+
.. automodule:: graphdoc.data.dspy_data.generation_data_helper
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.data.dspy\_data.quality\_data\_helper module
2+
=====================================================
3+
4+
.. automodule:: graphdoc.data.dspy_data.quality_data_helper
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:
Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
graphdoc.data.dspy\_data package
22
================================
33

4-
Submodules
5-
----------
6-
7-
graphdoc.data.dspy\_data.dspy\_data\_helper module
8-
--------------------------------------------------
9-
10-
.. automodule:: graphdoc.data.dspy_data.dspy_data_helper
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
14-
15-
graphdoc.data.dspy\_data.generation\_data\_helper module
16-
--------------------------------------------------------
17-
18-
.. automodule:: graphdoc.data.dspy_data.generation_data_helper
4+
.. automodule:: graphdoc.data.dspy_data
195
:members:
206
:undoc-members:
217
:show-inheritance:
8+
:noindex:
229

23-
graphdoc.data.dspy\_data.quality\_data\_helper module
24-
-----------------------------------------------------
25-
26-
.. automodule:: graphdoc.data.dspy_data.quality_data_helper
27-
:members:
28-
:undoc-members:
29-
:show-inheritance:
10+
Submodules
11+
----------
3012

31-
Module contents
32-
---------------
13+
.. toctree::
14+
:maxdepth: 4
3315

34-
.. automodule:: graphdoc.data.dspy_data
35-
:members:
36-
:undoc-members:
37-
:show-inheritance:
16+
graphdoc.data.dspy_data.dspy_data_helper
17+
graphdoc.data.dspy_data.generation_data_helper
18+
graphdoc.data.dspy_data.quality_data_helper
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.data.helper module
2+
===========================
3+
4+
.. automodule:: graphdoc.data.helper
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:

graphdoc/docs/graphdoc.data.local.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
graphdoc.data.local module
2+
==========================
3+
4+
.. automodule:: graphdoc.data.local
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:noindex:

0 commit comments

Comments
 (0)