Skip to content

Commit

Permalink
docs: use template to generate rst files in "Examples"
Browse files Browse the repository at this point in the history
  • Loading branch information
graczhual committed Nov 5, 2021
1 parent a4e5a68 commit 56e6a61
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 1,043 deletions.
4 changes: 4 additions & 0 deletions docs/code/LeedsSportsPose.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
dataset = Dataset("LeedsSportsPose", gas)
""""""

"""Read Dataset / list segment names"""
dataset.keys()
""""""

"""Read Dataset / get segment"""
segment = dataset[0]
""""""
Expand Down
4 changes: 4 additions & 0 deletions docs/code/NeolixOD.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
dataset = Dataset("NeolixOD", gas)
""""""

"""Read Dataset / list segment names"""
dataset.keys()
""""""

"""Read Dataset / get segment"""
segment = dataset[0]
""""""
Expand Down
39 changes: 39 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
"""Configuration file for the Sphinx documentation builder."""
import os
import sys
from pathlib import Path

import jinja2

sys.path.insert(0, str(Path(__file__).parents[2]))


Expand Down Expand Up @@ -79,3 +82,39 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ["_static"]

source_path = os.path.dirname(os.path.abspath(__file__))
pattern = os.environ.get("SPHINX_PATTERN")
single_doc = pattern is not None and pattern not in ("-api", "whatsnew")
include_api = pattern is None or pattern == "whatsnew"
example_path = os.path.join(source_path, "quick_start", "examples")
datasets = (
"Dogs Vs Cats",
"20 Newsgroups",
"BSTLD",
"Neolix OD",
"Leeds Sports Pose",
"THCHS-30",
)
label_types = (
"Classification",
"Classification",
"Box2D",
"Box3D",
"Keypoints2D",
"Sentence",
)
file_names = ("DogsVsCats", "Newsgroups20", "BSTLD", "NeolixOD", "LeedsSportsPose", "THCHS30")
for dataset_name, label_type, file_name in zip(datasets, label_types, file_names):
with open(os.path.join(example_path, "test.rst.template")) as f:
t = jinja2.Template(f.read())
with open(os.path.join(example_path, f"{file_name}.rst"), "w") as f:
f.write(
t.render(
include_api=include_api,
single_doc=(pattern if single_doc else None),
dataset_name=dataset_name,
label_type=label_type,
file_name=file_name,
)
)
182 changes: 0 additions & 182 deletions docs/source/quick_start/examples/BSTLD.rst

This file was deleted.

Loading

0 comments on commit 56e6a61

Please sign in to comment.