-
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.
Merge pull request #56 from kartverket/sphinx_deployment
Sphinx deployment
- Loading branch information
Showing
10 changed files
with
210 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
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,38 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath(".")) | ||
|
||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = "Automatisk Generalisering" | ||
copyright = "2024, Kartverket" | ||
author = "Kartverket" | ||
release = "0.0.1" | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = [ | ||
"sphinx.ext.autodoc", # Add autodoc extension | ||
"sphinx.ext.napoleon", # Uncomment this if you use Google/NumPy style docstrings | ||
"sphinx.ext.viewcode", # Uncomment this to add links to your source code | ||
"sphinx.ext.githubpages", # Add GitHub Pages extension | ||
] | ||
|
||
|
||
templates_path = ["_templates"] | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = "alabaster" | ||
html_static_path = ["_static"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. Automatisk Generalisering documentation master file, created by | ||
sphinx-quickstart on Tue Jan 23 13:29:36 2024. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to Automatisk Generalisering's documentation! | ||
===================================================== | ||
|
||
.. toctree:: | ||
# Start of auto-generated docs | ||
generated_docs/config | ||
generated_docs/custom_tools | ||
generated_docs/env_setup | ||
generated_docs/file_manager.n100 | ||
generated_docs/file_manager | ||
generated_docs/generalization.n100.building | ||
generated_docs/generalization.n100 | ||
generated_docs/generalization | ||
generated_docs/input_data | ||
generated_docs/modules | ||
# End of auto-generated docs | ||
|
||
# Manual documentation below | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
|
||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
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,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
set BUILDDIR=_build | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.https://www.sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
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) |