Skip to content

Commit

Permalink
add api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fishjojo committed Apr 26, 2024
1 parent 8e7070c commit 010c297
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build_doc.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env bash
export PYTHONPATH=$(pwd):$PYTHONPATH
pip install pyscfad

cd doc

pip install -r requirements.txt

./scripts/gendoc.sh

python make.py html

touch build/html/.nojekyll
11 changes: 11 additions & 0 deletions doc/scripts/gendoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Get PySCF path
PYSCFAD_PATH=$(python -c "import pyscfad; print(pyscfad.__path__[0])")

# Run sphinx
DESTINATION=source/api_reference/apidoc
LOGFILE=_api_docs.log

mkdir -p $DESTINATION
sphinx-apidoc -d 1 -T -e -f -o $DESTINATION $PYSCFAD_PATH "test" > ${LOGFILE}
5 changes: 5 additions & 0 deletions doc/source/api_reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
=============
API reference
=============

.. toctree::
:maxdepth: 1

apidoc/pyscfad
42 changes: 33 additions & 9 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
import warnings
import inspect

import pyscfad

project = 'PySCFAD'
copyright = '2021-2024, Xing Zhang'
author = 'Xing Zhang'
project = "pyscfad"
copyright = "2021-2024, Xing Zhang"
author = "Xing Zhang"

import pyscfad
version = str(pyscfad.__version__)
release = version

language = 'en'
language = "en"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -45,16 +44,25 @@
"sphinxemoji.sphinxemoji", # emoji
]

templates_path = ['_templates']
templates_path = ["_templates"]
source_suffix = [".rst"]
source_encoding = "utf-8"
master_doc = "index"
exclude_patterns = []

autosummary_generate = True
autodoc_typehints = "none"

numpydoc_show_class_members = False
numpydoc_show_inherited_class_members = False
numpydoc_attributes_as_param_list = False

pygments_style = "sphinx"

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

html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"
html_logo = "_static/pyscfad_logo.svg"
html_favicon = "_static/pyscfad_logo.svg"
html_sourcelink_suffix = ""
Expand All @@ -67,7 +75,7 @@
"doc_path": "doc/source",
}

html_static_path = ['_static']
html_static_path = ["_static"]
#html_css_files = ["css/pyscfad.css"]
html_js_files = ["custom-icon.js"]

Expand Down Expand Up @@ -155,3 +163,19 @@ def linkcode_resolve(domain, info) -> str | None:
f"https://github.com/fishjojo/pyscfad/blob/"
f"v{pyscfad.__version__}/pyscfad/{fn}{linespec}"
)

def rstjinja(app, docname, source) -> None:
"""
Render our pages as a jinja template for fancy templating goodness.
"""
# https://www.ericholscher.com/blog/2016/jul/25/integrating-jinja-rst-sphinx/
# Make sure we're outputting HTML
if app.builder.format != "html":
return
src = source[0]
rendered = app.builder.templates.render_string(src, app.config.html_context)
source[0] = rendered


def setup(app) -> None:
app.connect("source-read", rstjinja)

0 comments on commit 010c297

Please sign in to comment.