Skip to content

Commit

Permalink
Add structure of documentation (#80)
Browse files Browse the repository at this point in the history
* Add structure of documentation

* Install axidence

* Add documentation requirements

* Fix bug
  • Loading branch information
dachengx authored May 20, 2024
1 parent 5255c48 commit 41c34e8
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ resource_cache
*.gv
*.gv.svg
strax_test_data
build
docs/source/reference/*
docs/source/reference/release_notes.rst
2 changes: 2 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ formats:
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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 = source
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)
35 changes: 35 additions & 0 deletions docs/make.bat
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=source
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
6 changes: 6 additions & 0 deletions docs/make_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
make clean
rm -r source/reference
sphinx-apidoc -o source/reference ../axidence
rm source/reference/modules.rst
make html #SPHINXOPTS="-W --keep-going -n"
11 changes: 11 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# File for the requirements of the documentation
commonmark==0.9.1
graphviz==0.20.1
m2r==0.2.1
mistune==0.8.4
nbsphinx==0.8.9
recommonmark==0.7.1
sphinx==5.2.3
sphinx_rtd_theme==1.0.0
Jinja2==3.0.3
lxml_html_clean
10 changes: 10 additions & 0 deletions docs/source/build_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
from straxen.docs_utils import convert_release_notes


if __name__ == "__main__":
this_dir = os.path.dirname(os.path.realpath(__file__))
notes = os.path.join(this_dir, "..", "..", "HISTORY.md")
target = os.path.join(this_dir, "reference", "release_notes.rst")
pull_url = "https://github.com/XENONnT/axidence/pull"
convert_release_notes(notes, target, pull_url)
60 changes: 60 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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

import axidence

project = "XENON axidence"
copyright = "2024, axidence contributors, the XENON collaboration"

release = axidence.__version__
version = axidence.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"nbsphinx",
]

templates_path = ["_templates"]
exclude_patterns = [] # type: ignore


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

# -- Options for HTML output

html_theme = "sphinx_rtd_theme"
# html_static_path = ['_static']

# Lets disable notebook execution for now
nbsphinx_allow_errors = True
nbsphinx_execute = "never"


def setup(app):
# app.add_css_file('css/custom.css')
# Hack to import something from this dir. Apparently we're in a weird
# situation where you get a __name__ is not in globals KeyError
# if you just try to do a relative import...
import os
import sys

sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from build_release_notes import convert_release_notes

this_dir = os.path.dirname(os.path.realpath(__file__))
notes = os.path.join(this_dir, "..", "..", "HISTORY.md")
os.makedirs(os.path.join(this_dir, "reference"), exist_ok=True)
target = os.path.join(this_dir, "reference", "release_notes.rst")
pull_url = "https://github.com/XENONnT/axidence/pull"

convert_release_notes(notes, target, pull_url)
34 changes: 33 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,39 @@ Axidence is a strax-based data-driven accidental coincidence background simulati
:maxdepth: 1
:caption: Installation

installation.rst
installation

.. toctree::
:maxdepth: 1
:caption: Plugins Factory

plugins_factory

.. toctree::
:maxdepth: 1
:caption: Salting Plugins

salting_plugins
reference/salting_plugins_tree

.. toctree::
:maxdepth: 1
:caption: Pairing Plugins

pairing_plugins
reference/pairing_plugins_tree

.. toctree::
:maxdepth: 1
:caption: Reference

reference/axidence

.. toctree::
:maxdepth: 2
:caption: Release notes

reference/release_notes

Indices and tables
==================
Expand Down
Empty file added docs/source/pairing_plugins.rst
Empty file.
Empty file added docs/source/plugins_factory.rst
Empty file.
Empty file added docs/source/salting_plugins.rst
Empty file.

0 comments on commit 41c34e8

Please sign in to comment.