Skip to content

Commit b5c023a

Browse files
TLSDCgasse
andauthored
automated readthedocs (#177)
* adding readthedocs stuff * adding .readthedocs.yml * ReadTheDoc base template * fixing unused dep * fancier theme options * adding some documentation * adding some init files * adding workflow * fixing rtd git workflow * testing some more stuff * triggers only on non dev tags * changing workflows * Explicit tag push --------- Co-authored-by: Maxime Gasse <[email protected]>
1 parent c52b7cd commit b5c023a

File tree

21 files changed

+362
-5
lines changed

21 files changed

+362
-5
lines changed

.github/workflows/pypi.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ name: Build and Publish
22
# based on official doc
33
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
44

5-
on: [push, workflow_dispatch]
5+
on:
6+
push:
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
610

711
jobs:
812
build:
@@ -31,7 +35,6 @@ jobs:
3135

3236
publish-to-pypi:
3337
name: Publish to PyPI
34-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes # tweak so it doesnt publish all tags
3538
needs:
3639
- build
3740
runs-on: ubuntu-22.04
@@ -40,6 +43,24 @@ jobs:
4043
id-token: write # IMPORTANT: mandatory for trusted publishing
4144

4245
steps:
46+
- name: Extract tag name
47+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
48+
49+
- name: Validate tag format
50+
id: validate_tag
51+
run: |
52+
if [[ "${{ env.TAG_NAME }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$ ]]; then
53+
echo "valid=true" >> $GITHUB_ENV
54+
else
55+
echo "valid=false" >> $GITHUB_ENV
56+
fi
57+
58+
- name: Exit if invalid tag
59+
if: env.valid == 'false'
60+
run: |
61+
echo "The tag ${{ env.TAG_NAME }} is not a valid semantic version. Exiting."
62+
exit 1
63+
4364
- name: Download all the distribution packages
4465
uses: actions/download-artifact@v4
4566
with:

.github/workflows/readthedocs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Update Docs with Versioning
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build-docs:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: 3.x
26+
27+
- name: Install Dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install sphinx
31+
32+
- name: Run Sphinx-apidoc
33+
run: |
34+
cd docs
35+
sphinx-apidoc ../src -o ./source
36+
37+
- name: Commit and Push to Generated Docs Branch
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
git config --global user.name "github-actions[bot]"
42+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
43+
git checkout -b generated-docs
44+
git add .
45+
git commit -m "Update docs for version $GITHUB_REF_NAME [skip ci]" || echo "No changes to commit"
46+
git push origin generated-docs --force
47+
git tag docs/$GITHUB_REF_NAME
48+
git push origin tag docs/$GITHUB_REF_NAME

.readthedocs.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.12"
12+
# You can also specify other tool versions:
13+
# nodejs: "20"
14+
# rust: "1.70"
15+
# golang: "1.20"
16+
17+
# Build documentation in the "docs/" directory with Sphinx
18+
sphinx:
19+
configuration: docs/source/conf.py
20+
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
21+
# builder: "dirhtml"
22+
# Fail on all warnings to avoid broken references
23+
# fail_on_warning: true
24+
25+
# Optionally build your docs in additional formats such as PDF and ePub
26+
# formats:
27+
# - pdf
28+
# - epub
29+
30+
# Optional but recommended, declare the Python requirements required
31+
# to build your documentation
32+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33+
python:
34+
install:
35+
- requirements: docs/source/requirements.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/source/conf.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
import os
10+
import subprocess
11+
12+
13+
# Automatically retrieve the project version from Git
14+
def get_version():
15+
try:
16+
return subprocess.check_output(["git", "describe", "--tags"], encoding="utf-8").strip()
17+
except Exception:
18+
return "0.0.0"
19+
20+
21+
project = "AgentLab"
22+
author = "ServiceNow"
23+
release = get_version() # Full version string including tags
24+
version = release # Short version (e.g., 1.0)
25+
26+
27+
# -- General configuration ---------------------------------------------------
28+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
29+
extensions = [
30+
"sphinx.ext.duration",
31+
"sphinx.ext.doctest",
32+
"sphinx.ext.autodoc",
33+
"sphinx.ext.autosummary",
34+
"sphinx.ext.intersphinx",
35+
# "myst_parser", # Add this to enable Markdown parsing
36+
"sphinx.ext.napoleon",
37+
]
38+
39+
intersphinx_mapping = {
40+
"rtd": ("https://docs.readthedocs.io/en/stable/", None),
41+
"python": ("https://docs.python.org/3/", None),
42+
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
43+
}
44+
intersphinx_disabled_domains = ["std"]
45+
46+
autodoc_default_options = {
47+
"members": True,
48+
"undoc-members": True,
49+
"show-inheritance": True,
50+
}
51+
52+
source_suffix = {
53+
".rst": "restructuredtext",
54+
}
55+
56+
57+
templates_path = ["_templates"]
58+
exclude_patterns = []
59+
60+
61+
# -- Options for HTML output -------------------------------------------------
62+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
63+
64+
html_theme = "sphinx_rtd_theme"
65+
html_theme_options = {
66+
"navigation_depth": -1,
67+
"collapse_navigation": False,
68+
"display_version": True,
69+
"version_selector": True,
70+
}
71+
html_static_path = ["_static"]
72+
73+
import sys
74+
75+
sys.path.insert(0, os.path.abspath("../../src"))

docs/source/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. AgentLab documentation master file, created by
2+
sphinx-quickstart on Tue Nov 26 11:21:39 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
AgentLab documentation
7+
======================
8+
9+
ReadTheDoc Page for AgentLab: https://agentlab.readthedocs.io/en/latest/
10+
11+
12+
.. autosummary::
13+
:toctree:
14+
:recursive:
15+
16+
agentlab.agents
17+
agentlab.analyze
18+
agentlab.llm
19+
agentlab.experiments
20+
agentlab.ui_assistant

docs/source/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
agentlab
2+
sphinx-rtd-theme

0 commit comments

Comments
 (0)