-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d815ea
commit 641c39a
Showing
8 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build and Deploy Sphinx Documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install Dependencies | ||
run: | | ||
pip install sphinx | ||
- name: Generate .rst files | ||
run: | | ||
sphinx-apidoc -o generated_docs/ . | ||
- name: Update index.rst | ||
run: | | ||
update_index_rst.py | ||
- name: Build Sphinx Documentation | ||
run: | | ||
make html | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./_build/html | ||
branch: gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
# Define the directory where auto-generated docs are stored | ||
docs_dir = "generated_docs" | ||
# List of .rst files to ignore | ||
ignore_files = ["conf.rst", "update_index_rst.rst"] | ||
|
||
# Gather all .rst files in the specified directory, excluding those in ignore_files | ||
entries = [ | ||
" generated_docs/" + f.replace(".rst", "") # Maintain indentation for toctree | ||
for f in os.listdir(docs_dir) | ||
if f.endswith(".rst") and f not in ignore_files | ||
] | ||
|
||
# Join the entries with newlines to form the toctree content | ||
toctree_entries = "\n".join(entries) + "\n" | ||
|
||
# Open index.rst to read its contents | ||
with open("index.rst", "r") as file: | ||
lines = file.readlines() | ||
|
||
# Find where the auto-generated toctree section starts and ends based on markers | ||
start_marker = "# Start of auto-generated docs" | ||
end_marker = "# End of auto-generated docs" | ||
start_line = next(i for i, line in enumerate(lines) if start_marker in line) + 1 | ||
end_line = next(i for i, line in enumerate(lines) if end_marker in line) | ||
|
||
|
||
# Remove existing auto-generated toctree entries | ||
del lines[start_line:end_line] | ||
|
||
# Insert the new auto-generated toctree entries | ||
lines[start_line:start_line] = [toctree_entries] | ||
|
||
# Write the modified contents back to index.rst | ||
with open("index.rst", "w") as file: | ||
file.writelines(lines) |