Skip to content

Commit 52ab113

Browse files
authored
Replace pydoc generation with mkdoc (#410)
Changes: * Completely replaces pydoc with mkdoc. This is done to allow more expressiveness in docstrings. They now can include code-blocks, links to other functions, all the sort of snazzy things that come from rendering docstrings natively with rst. * Moves the py client docs from a directory in the main documentation to its own page (which links back to the original page). Same idea as the rest api documentation. * Removes the link to py client documentation in the user section. Now the only way to get to it is from the top menu.
1 parent e49dc41 commit 52ab113

File tree

10 files changed

+88
-287
lines changed

10 files changed

+88
-287
lines changed

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ Developer documentation will help you get started. Peruse some common REST API &
6161
Client API references that are directly derived from Rucio's python
6262
libraries. We also have a contribution guide for those who wish to pitch in.
6363

64-
- [Client API Documentation](client_api/accountclient)
65-
- REST API Documentation
64+
- [Client API Documentation](pathname:///html/site/client.html)
65+
- [REST API Documentation](pathname:///html/rest_api_doc.html)
6666
- [Contributing guide](contributing)
6767

6868
## Contributing to the Documentation

docs/user/developing_with_rucio.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rucio_client.ping()
1818
```
1919

2020
The methods are separated per resource type. The API in full can be viewed
21-
[here](/client_api/accountclient).
21+
[here](pathname:///html/site/client.html).
2222

2323
### Errors and Exceptions
2424

tools/build_documentation.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mkdir -p "$SCRIPT_DIR"/../website/static/html/
3535

3636
cp -r "$AUTO_GENERATED"/rest_api_doc_spec.yaml "$SCRIPT_DIR"/../website/static/yaml/
3737
cp -r "$AUTO_GENERATED"/rest_api_doc.html "$SCRIPT_DIR"/../website/static/html/
38-
cp -r "$AUTO_GENERATED"/client_api "$DOCS"
38+
cp -r "$AUTO_GENERATED"/site "$SCRIPT_DIR"/../website/static/html/
3939
cp -r "$AUTO_GENERATED"/bin "$DOCS"
4040

4141

tools/run_in_docker/generate_client_api_docs.sh

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,11 @@ set -e
44

55
echo "Generating the Client Api Docs..."
66

7-
pip install --upgrade "pydoc-markdown>3" &> /dev/null
7+
pip install --upgrade mkdocs mkdocs-gen-files mkdocstrings-python mkdocs-material
88

99
mkdir -p /auto_generated/client_api
10-
for f in rucio/lib/rucio/client/*.py; do
11-
if [[ $f =~ "__init__" ]] || [[ $f =~ "richclient" ]]; then
12-
continue
13-
fi
1410

15-
executable_name=$(basename "$f" ".py")
11+
python3 generate_client_api_pages.py
12+
mkdocs build --clean --no-directory-urls
1613

17-
config="
18-
processors:
19-
- type: rucio_processor.RucioProcessor
20-
renderer:
21-
type: rucio_renderer.RucioRenderer"
22-
content=$(PYTHONPATH=. pydoc-markdown -I rucio/lib/rucio/client -m "$executable_name" "$config")
23-
24-
echo "$content" > /auto_generated/client_api/"$executable_name".md
25-
done
14+
cp -r site /auto_generated/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Generate the code reference pages and navigation."""
2+
3+
import os
4+
from pathlib import Path
5+
6+
import mkdocs_gen_files
7+
8+
src = Path("rucio/lib/rucio/client/")
9+
root = src.parent
10+
doc_path = "/auto_generated/client_api"
11+
files = os.listdir(doc_path)
12+
for file in files:
13+
os.remove(f"{doc_path}/{file}")
14+
15+
16+
py_files = [f for f in list(src.rglob("*.py")) if "__init__.py" not in f.name]
17+
18+
for path in py_files:
19+
module_name = path.name.split(".py")[0]
20+
21+
try:
22+
full_doc_path = Path(f"{doc_path}/{module_name}.md")
23+
__import__(f"rucio.client.{module_name}")
24+
with mkdocs_gen_files.open(full_doc_path, "a") as fd:
25+
module_path = path.relative_to(src).with_suffix("")
26+
fd.write(f"::: rucio.client.{module_path}")
27+
fd.write("\n\n")
28+
29+
except ImportError:
30+
print(f"Could not access client page for {module_name}")
31+
pass

tools/run_in_docker/mkdocs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
site_name: "Rucio Python Client Documentation"
2+
repo_url: https://github.com/rucio/rucio/
3+
site_url: https://rucio.cern.ch/documentation/
4+
copyright: "Copyright © 2024 CERN"
5+
docs_dir: /auto_generated/client_api
6+
use_directory_urls: true
7+
not_in_nav:
8+
/auto_generated
9+
10+
theme:
11+
name: material
12+
logo: ../../img/rucio_horizontaled_black_cropped.svg
13+
extra_css: ../../../src/customTheme.css
14+
extra:
15+
homepage: /documentation/
16+
features:
17+
- content.code.copy
18+
- toc.follow
19+
palette:
20+
- scheme: default
21+
primary: white
22+
toggle:
23+
icon: material/brightness-7
24+
name: Switch to dark mode
25+
- scheme: slate
26+
primary: white
27+
toggle:
28+
icon: material/brightness-4
29+
name: Switch to light mode
30+
31+
markdown_extensions:
32+
- toc:
33+
permalink: true
34+
plugins:
35+
- search
36+
- autorefs
37+
- mkdocstrings:
38+
default_handler: python
39+
handlers:
40+
python:
41+
options:
42+
members_order: "source"
43+
heading_level: 2
44+
show_source: false
45+
allow_inspection: false
46+
merge_init_into_class: true
47+
docstring_style: "sphinx"
48+
show_bases: false

tools/run_in_docker/rucio_processor.py

Lines changed: 0 additions & 193 deletions
This file was deleted.

tools/run_in_docker/rucio_renderer.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)