Skip to content

Commit c582ae2

Browse files
authored
✨ basic docs (#32)
* ✨ basic docs - file content organization still to fix * ✨ link images in README using relative docs parameter - unfortunately does not work with href links as it seems * 🎨🐛 fix and improve type anntoations * 🐛 remove non existing attribute * 🐛 fix imports after merge * 🚚 move examples to docs, update documentation, relat. paths in config... - sphinx: easier to integrate notebook example into documentation - 🐛 fixed one filepath: example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example_edgelist.csv ("_edgelist" was missing) * ✨ add optional dependencies using poetry syntax this should now work: pip install "-e[docs]" * ✨ add quatro-cli python package and try testing build of docs * 🐛 misstyped quarto (again...) * 🐛 add parquet as dependency for pandas * 🐛 don't fail on warnings (especially with nitpicky mode enabled)
1 parent 9ee2b4c commit c582ae2

30 files changed

+347
-174
lines changed

.github/workflows/docs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test documentation building (until it's moved to ReadTheDocs)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
test:
13+
name: Test
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
cache: 'pip' # caching pip dependencies
25+
cache-dependency-path: '**/pyproject.toml'
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e .[docs,quarto]
30+
- name: Build references
31+
run: |
32+
cd docs
33+
sphinx-apidoc --force --implicit-namespaces --module-first -o reference ../vuegen
34+
- name: Build documentation
35+
run: |
36+
cd docs
37+
sphinx-build -n --keep-going -b html ./ ./_build/
38+
- name: save artifacts
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: Sphinx_${{ matrix.python-version }}
42+
path: docs/_build/

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<div align="center">
2-
<img width="300px" src="docs/images/vuegen_logo.svg">
3-
</div>
4-
1+
<!-- <div align="center">
2+
<img width="300px" src="images/vuegen_logo.svg">
3+
</div> -->
4+
![VueGen Logo](docs/images/vuegen_logo.svg)
55
-----------------
6-
76
<p align="center">
87
VueGen is a Python library that automates the creation of scientific reports.
98
</p>
@@ -19,19 +18,22 @@ VueGen automates the creation of scientific reports based on a YAML configuratio
1918

2019
An overview of the VueGen workflow is shown in the figure below:
2120

22-
<p align="center">
21+
<!-- <p align="center">
2322
<figure>
24-
<img width="650px" src="docs/images/vuegen_graph_abstract.png" alt="VueGen overview"/>
23+
<img width="650px" src="images/vuegen_graph_abstract.png" alt="VueGen overview"/>
2524
</figure>
26-
</p>
25+
</p> -->
26+
![VueGen Abstract](docs/images/vuegen_graph_abstract.png)
2727

2828
Also, the class diagram for the project is presented below to illustrate the architecture and relationships between classes:
2929

30-
<p align="center">
30+
<!-- <p align="center">
3131
<figure>
32-
<img width="650px" src="docs/images/vuegen_classdiagram_noattmeth.png" alt="VueGen class diagram"/>
32+
<img width="650px" src="images/vuegen_classdiagram_noattmeth.png" alt="VueGen class diagram"/>
3333
</figure>
34-
</p>
34+
</p> -->
35+
36+
![VueGen Class Diagram](docs/images/vuegen_classdiagram_noattmeth.png)
3537

3638
## Installation
3739

@@ -67,6 +69,7 @@ quarto check
6769
## Execution
6870

6971
```bash
72+
cd docs
7073
python vuegen/main.py --config example_data/MicW2Graph/report_config_micw2graph.yaml --report_type streamlit
7174
```
7275

docs/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# apidocs
2+
reference
3+
# builds
4+
_build
5+
quarto_report
6+
logs
7+
jupyter_execute

docs/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Docs creation
2+
3+
In order to build the docs you need to
4+
5+
1. install sphinx and additional support packages
6+
2. build the package reference files
7+
3. run sphinx to create a local html version
8+
9+
The documentation is build using readthedocs automatically.
10+
11+
Install the docs dependencies of the package (as speciefied in toml):
12+
13+
```bash
14+
# in main folder
15+
# pip install ".[docs]"
16+
poetry install --with docs
17+
```
18+
19+
## Build docs using Sphinx command line tools
20+
21+
Command to be run from `path/to/docs`, i.e. from within the `docs` package folder:
22+
23+
Options:
24+
- `--separate` to build separate pages for each (sub-)module
25+
26+
```bash
27+
# pwd: docs
28+
# apidoc
29+
sphinx-apidoc --force --implicit-namespaces --module-first -o reference ../vuegen
30+
# build docs
31+
sphinx-build -n -W --keep-going -b html ./ ./_build/
32+
```
33+
34+
## Include repo README.md into docs
35+
36+
Relative links are used in the main README, which need to be resolved when building. It's
37+
possible to include the a `relative-docs` option if one uses `index.md` ([see docs](https://myst-parser.readthedocs.io/en/latest/faq/index.html#include-a-file-from-outside-the-docs-folder-like-readme-md)). This does not work
38+
with `href` links, only native markdown links.
39+

docs/conf.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
from importlib import metadata
15+
16+
# -- Project information -----------------------------------------------------
17+
18+
project = "mockup"
19+
copyright = "2024, Multiomics-Analytics-Group"
20+
author = "Multiomics-Analytics-Group, Sebastián Ayala Ruano, Henry Webel, Alberto Santos"
21+
PACKAGE_VERSION = metadata.version("vuegen")
22+
version = PACKAGE_VERSION
23+
release = PACKAGE_VERSION
24+
25+
26+
# -- General configuration ---------------------------------------------------
27+
28+
# Add any Sphinx extension module names here, as strings. They can be
29+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30+
# ones.
31+
extensions = [
32+
"sphinx.ext.autodoc",
33+
"sphinx.ext.autodoc.typehints",
34+
"sphinx.ext.viewcode",
35+
"sphinx.ext.napoleon",
36+
"sphinx.ext.intersphinx",
37+
"sphinx_new_tab_link",
38+
"myst_nb",
39+
]
40+
41+
# https://myst-nb.readthedocs.io/en/latest/computation/execute.html
42+
nb_execution_mode = "auto"
43+
44+
myst_enable_extensions = ["dollarmath", "amsmath"]
45+
46+
# Plolty support through require javascript library
47+
# https://myst-nb.readthedocs.io/en/latest/render/interactive.html#plotly
48+
html_js_files = [
49+
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
50+
]
51+
52+
# https://myst-nb.readthedocs.io/en/latest/configuration.html
53+
# Execution
54+
nb_execution_raise_on_error = True
55+
# Rendering
56+
nb_merge_streams = True
57+
58+
# https://myst-nb.readthedocs.io/en/latest/authoring/custom-formats.html#write-custom-formats
59+
# ! if you use it, then you cannot directly execute the notebook in the browser in colab
60+
# (the file needs to be fetched from the repository)
61+
# just keep both syncing it using papermill
62+
# nb_custom_formats = {".py": ["jupytext.reads", {"fmt": "py:percent"}]}
63+
64+
# Add any paths that contain templates here, relative to this directory.
65+
templates_path = ["_templates"]
66+
67+
# List of patterns, relative to source directory, that match files and
68+
# directories to ignore when looking for source files.
69+
# This pattern also affects html_static_path and html_extra_path.
70+
exclude_patterns = [
71+
"_build",
72+
"Thumbs.db",
73+
".DS_Store",
74+
"jupyter_execute",
75+
"conf.py",
76+
]
77+
78+
79+
# Intersphinx options
80+
intersphinx_mapping = {
81+
"python": ("https://docs.python.org/3", None),
82+
"networkx": ("https://networkx.org/documentation/stable/", None),
83+
"pyvis": ("https://pyvis.readthedocs.io/en/stable/", None),
84+
# "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
85+
# "scikit-learn": ("https://scikit-learn.org/stable/", None),
86+
# "matplotlib": ("https://matplotlib.org/stable/", None),
87+
}
88+
89+
# -- Options for HTML output -------------------------------------------------
90+
91+
# The theme to use for HTML and HTML Help pages. See the documentation for
92+
# a list of builtin themes.
93+
# See:
94+
# https://github.com/executablebooks/MyST-NB/blob/master/docs/conf.py
95+
# html_title = ""
96+
html_theme = "sphinx_book_theme"
97+
# html_logo = "_static/logo-wide.svg"
98+
# html_favicon = "_static/logo-square.svg"
99+
html_theme_options = {
100+
"github_url": "https://github.com/Multiomics-Analytics-Group/vuegen",
101+
"repository_url": "https://github.com/Multiomics-Analytics-Group/vuegen",
102+
"repository_branch": "main",
103+
"home_page_in_toc": True,
104+
"path_to_docs": "docs",
105+
"show_navbar_depth": 1,
106+
"use_edit_page_button": True,
107+
"use_repository_button": True,
108+
"use_download_button": True,
109+
"launch_buttons": {
110+
"colab_url": "https://colab.research.google.com"
111+
# "binderhub_url": "https://mybinder.org",
112+
# "notebook_interface": "jupyterlab",
113+
},
114+
"navigation_with_keys": False,
115+
}
116+
117+
# Add any paths that contain custom static files (such as style sheets) here,
118+
# relative to this directory. They are copied after the builtin static files,
119+
# so a file named "default.css" will overwrite the builtin "default.css".
120+
# html_static_path = ["_static"]
121+
122+
123+
# -- Setup for sphinx-apidoc -------------------------------------------------
124+
125+
# Read the Docs doesn't support running arbitrary commands like tox.
126+
# sphinx-apidoc needs to be called manually if Sphinx is running there.
127+
# https://github.com/readthedocs/readthedocs.org/issues/1139
128+
129+
if os.environ.get("READTHEDOCS") == "True":
130+
from pathlib import Path
131+
132+
PROJECT_ROOT = Path(__file__).parent.parent
133+
PACKAGE_ROOT = PROJECT_ROOT / "vuegen"
134+
135+
def run_apidoc(_):
136+
from sphinx.ext import apidoc
137+
138+
apidoc.main(
139+
[
140+
"--force",
141+
"--implicit-namespaces",
142+
"--module-first",
143+
"--separate",
144+
"-o",
145+
str(PROJECT_ROOT / "docs" / "reference"),
146+
str(PACKAGE_ROOT),
147+
str(PACKAGE_ROOT / "*.c"),
148+
str(PACKAGE_ROOT / "*.so"),
149+
]
150+
)
151+
152+
def setup(app):
153+
app.connect("builder-inited", run_apidoc)

0 commit comments

Comments
 (0)