Skip to content

Commit 094099b

Browse files
authored
Merge branch 'main' into tkp/zm
2 parents 692efd6 + 330fa79 commit 094099b

File tree

9 files changed

+228
-92
lines changed

9 files changed

+228
-92
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
name: Docs
2-
32
on:
43
push:
5-
branches:
6-
- main
7-
tags:
8-
- v*
9-
paths-ignore:
10-
- LICENSE
11-
- README.md
12-
4+
branches: ["main"]
5+
tags: ["v*"]
6+
paths-ignore: ["LICENSE", "README.md"]
137
permissions:
148
contents: write
15-
169
jobs:
1710
docs:
1811
runs-on: ubuntu-latest
1912
steps:
20-
- uses: actions/checkout@v4
21-
- uses: actions/setup-python@v5
22-
- run: pip install .
23-
- run: make docs
24-
- name: Deploy
25-
uses: peaceiris/actions-gh-pages@v4
13+
- uses: actions-ext/yardang@main
2614
with:
27-
publish_branch: gh-pages
28-
github_token: ${{ secrets.GITHUB_TOKEN }}
29-
publish_dir: docs/html
30-
force_orphan: true
15+
token: ${{ secrets.GITHUB_TOKEN }}

docs/src/configuration.md

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,30 @@ Whether or not to use [Sphinx AutoAPI](https://sphinx-autoapi.readthedocs.io/en/
113113
use-autoapi = true
114114
```
115115

116-
## [Autodoc Pydantic](https://autodoc-pydantic.readthedocs.io/en/stable/users/examples.html) arguments
116+
## Sphinx Options
117117

118-
[Configuration for Autodoc Pydantic](https://autodoc-pydantic.readthedocs.io/en/stable/users/configuration.html).
118+
```toml
119+
[tool.yardang]
120+
html_theme_options = {}
121+
html_static_path = []
122+
html_css_files = []
123+
html_js_files = []
124+
source_suffix = []
125+
exclude_patterns = []
126+
language = "en"
127+
pygments_style = "sphinx"
128+
```
129+
130+
131+
## [Myst](https://myst-parser.readthedocs.io/en/latest/#)
119132

120133
```toml
121134
[tool.yardang]
122-
autodoc_pydantic_model_show_config_summary = false
123-
autodoc_pydantic_model_show_validator_summary = false
124-
autodoc_pydantic_model_show_validator_members = false
125-
autodoc_pydantic_field_list_validators = false
126-
autodoc_pydantic_field_show_constraints = false
127-
autodoc_pydantic_model_member_order = "bysource"
128-
autodoc_pydantic_model_show_json = true
129-
autodoc_pydantic_settings_show_json = false
130-
autodoc_pydantic_model_show_field_summary = false
135+
myst_enable_extensions = ["colon_fence"]
136+
myst_fence_as_directive = ["mermaid"]
131137
```
132138

133-
## Myst-NB
139+
## [Myst-NB](https://myst-nb.readthedocs.io/en/latest/#)
134140

135141
```toml
136142
[tool.yardang]
@@ -158,6 +164,22 @@ An example follows:
158164
../notebooks/example
159165
```
160166

167+
## [Autodoc Pydantic](https://autodoc-pydantic.readthedocs.io/en/stable/users/examples.html) arguments
168+
169+
[Configuration for Autodoc Pydantic](https://autodoc-pydantic.readthedocs.io/en/stable/users/configuration.html).
170+
171+
```toml
172+
[tool.yardang]
173+
autodoc_pydantic_model_show_config_summary = false
174+
autodoc_pydantic_model_show_validator_summary = false
175+
autodoc_pydantic_model_show_validator_members = false
176+
autodoc_pydantic_field_list_validators = false
177+
autodoc_pydantic_field_show_constraints = false
178+
autodoc_pydantic_model_member_order = "bysource"
179+
autodoc_pydantic_model_show_json = true
180+
autodoc_pydantic_settings_show_json = false
181+
autodoc_pydantic_model_show_field_summary = false
182+
```
161183

162184
## Mermaid
163185

@@ -207,3 +229,23 @@ graph TD
207229
Z(Pay vendor invoice) --->R
208230
AA([Finish])
209231
```
232+
233+
## GitHub Admonitions
234+
235+
GitHub admonitions are automatically translated to sphinx.
236+
237+
> [!NOTE]
238+
> Note content
239+
240+
> [!TIP]
241+
> Tip content
242+
243+
> [!IMPORTANT]
244+
> Important content
245+
246+
> [!WARNING]
247+
> Warning content
248+
249+
> [!CAUTION]
250+
> Caution content
251+

docs/src/overview.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,17 @@ The following yaml should be all it takes to integrate your project with GitHub
3333
name: Docs
3434
on:
3535
push:
36-
branches:
37-
- main
36+
branches: ["main"]
37+
tags: ["v*"]
38+
paths-ignore: ["LICENSE", "README.md"]
3839
permissions:
39-
contents: write
40+
contents: write
4041
jobs:
4142
docs:
4243
runs-on: ubuntu-latest
4344
steps:
44-
- uses: actions/checkout@v4
45-
- uses: actions/setup-python@v5
45+
- uses: actions-ext/yardang@main
4646
with:
47-
python-version: 3.11
48-
- run: pip install .
49-
- run: pip install yardang
50-
- run: yardang build
51-
- name: Deploy
52-
uses: peaceiris/actions-gh-pages@v4
53-
with:
54-
publish_branch: gh-pages
55-
github_token: ${{ secrets.GITHUB_TOKEN }}
56-
publish_dir: docs/html
47+
token: ${{ secrets.GITHUB_TOKEN }}
48+
5749
```

pyproject.toml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [{name = "the yardang authors", email = "[email protected]"}]
88
description="Easily generate sphinx documentation"
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }
11-
version = "0.1.5"
11+
version = "0.1.8"
1212
requires-python = ">=3.9"
1313
keywords = []
1414

@@ -60,7 +60,7 @@ develop = [
6060
yardang = "yardang.cli:main"
6161

6262
[tool.bumpversion]
63-
current_version = "0.1.5"
63+
current_version = "0.1.8"
6464
commit = true
6565
tag = false
6666

@@ -123,6 +123,9 @@ testpaths = "yardang/tests"
123123
[tool.ruff]
124124
line-length = 150
125125

126+
[tool.ruff.lint]
127+
extend-select = ["I"]
128+
126129
[tool.ruff.lint.isort]
127130
combine-as-imports = true
128131
default-section = "third-party"
@@ -141,3 +144,31 @@ pages = [
141144
"docs/src/configuration.md",
142145
]
143146
use-autoapi = true
147+
148+
# Below are defaults, just to ensure working
149+
# sphinx
150+
html_theme_options = {"switcher" = { "json_url" = "https://mysite.org/en/latest/_static/switcher.json"}}
151+
html_static_path = ["test"]
152+
html_css_files = []
153+
html_js_files = []
154+
source_suffix = []
155+
exclude_patterns = []
156+
language = "en"
157+
pygments_style = "sphinx"
158+
159+
# myst/myst-nb
160+
myst_enable_extensions = ["colon_fence"]
161+
myst_fence_as_directive = ["mermaid"]
162+
nb_execution_mode = "off"
163+
nb_execution_excludepatterns = []
164+
165+
# autodoc/autodoc-pydantic
166+
autodoc_pydantic_model_show_config_summary = false
167+
autodoc_pydantic_model_show_validator_summary = false
168+
autodoc_pydantic_model_show_validator_members = false
169+
autodoc_pydantic_field_list_validators = false
170+
autodoc_pydantic_field_show_constraints = false
171+
autodoc_pydantic_model_member_order = "bysource"
172+
autodoc_pydantic_model_show_json = true
173+
autodoc_pydantic_settings_show_json = false
174+
autodoc_pydantic_model_show_field_summary = false

yardang/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.5"
1+
__version__ = "0.1.8"

yardang/build.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os.path
22
from contextlib import contextmanager
3-
from jinja2 import Environment, FileSystemLoader
43
from pathlib import Path
54
from tempfile import TemporaryDirectory
65
from typing import List, Optional
6+
7+
from jinja2 import Environment, FileSystemLoader
8+
79
from .utils import get_config
810

911
__all__ = ("generate_docs_configuration",)
@@ -70,31 +72,33 @@ def generate_docs_configuration(
7072
source_dir = os.path.curdir
7173

7274
configuration_args = {}
73-
for f in (
74-
# autodoc/autodoc-pydantic
75-
"autodoc_pydantic_model_show_config_summary",
76-
"autodoc_pydantic_model_show_validator_summary",
77-
"autodoc_pydantic_model_show_validator_members",
78-
"autodoc_pydantic_field_list_validators",
79-
"autodoc_pydantic_field_show_constraints",
80-
"autodoc_pydantic_model_member_order",
81-
"autodoc_pydantic_model_show_json",
82-
"autodoc_pydantic_settings_show_json",
83-
"autodoc_pydantic_model_show_field_summary",
75+
for config_option, default in {
76+
# sphinx generic
77+
"html_theme_options": {},
78+
"html_static_path": [],
79+
"html_css_files": [],
80+
"html_js_files": [],
81+
"source_suffix": [],
82+
"exclude_patterns": [],
83+
"language": "en",
84+
"pygments_style": "sphinx",
8485
# myst/myst-nb
85-
"nb_execution_mode",
86-
"nb_execution_excludepatterns",
87-
):
88-
default_value = {
89-
# autodoc/autodoc-pydantic
90-
"autodoc_pydantic_model_member_order": '"bysource"',
91-
"autodoc_pydantic_model_show_json": True,
92-
# myst/myst-nb
93-
"nb_execution_excludepatterns": [],
94-
"nb_execution_mode": "off",
95-
}.get(f, False)
96-
config_value = get_config(section=f"{f}")
97-
configuration_args[f] = default_value if config_value is None else config_value
86+
"myst_enable_extensions": ["colon_fence"],
87+
"myst_fence_as_directive": ["mermaid"],
88+
"nb_execution_mode": "off",
89+
"nb_execution_excludepatterns": [],
90+
# autodoc/autodoc-pydantic
91+
"autodoc_pydantic_model_show_config_summary": None,
92+
"autodoc_pydantic_model_show_validator_summary": None,
93+
"autodoc_pydantic_model_show_validator_members": None,
94+
"autodoc_pydantic_field_list_validators": None,
95+
"autodoc_pydantic_field_show_constraints": None,
96+
"autodoc_pydantic_model_member_order": "bysource",
97+
"autodoc_pydantic_model_show_json": True,
98+
"autodoc_pydantic_settings_show_json": None,
99+
"autodoc_pydantic_model_show_field_summary": None,
100+
}.items():
101+
configuration_args[config_option] = get_config(section=config_option) or default
98102
# create a temporary directory to store the conf.py file in
99103
with TemporaryDirectory() as td:
100104
templateEnv = Environment(loader=FileSystemLoader(searchpath=str(Path(__file__).parent.resolve())))

yardang/cli.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,52 @@
1-
from sys import executable, stderr, stdout
1+
from pathlib import Path
22
from subprocess import Popen
3+
from sys import executable, stderr, stdout
34
from time import sleep
4-
from typer import Typer
5+
from typing import List, Optional
6+
7+
from typer import Exit, Typer
58

69
from .build import generate_docs_configuration
710

811

9-
def build(quiet: bool = False, debug: bool = False):
10-
with generate_docs_configuration() as file:
12+
def build(
13+
*,
14+
quiet: bool = False,
15+
debug: bool = False,
16+
pdb: bool = False,
17+
project: str = "",
18+
title: str = "",
19+
module: str = "",
20+
description: str = "",
21+
author: str = "",
22+
copyright: str = "",
23+
version: str = "",
24+
theme: str = "furo",
25+
docs_root: str = "",
26+
root: str = "",
27+
cname: str = "",
28+
pages: Optional[List[Path]] = None,
29+
use_autoapi: Optional[bool] = None,
30+
custom_css: Optional[Path] = None,
31+
custom_js: Optional[Path] = None,
32+
):
33+
with generate_docs_configuration(
34+
project=project,
35+
title=title,
36+
module=module,
37+
description=description,
38+
author=author,
39+
copyright=copyright,
40+
version=version,
41+
theme=theme,
42+
docs_root=docs_root,
43+
root=root,
44+
cname=cname,
45+
pages=pages,
46+
use_autoapi=use_autoapi,
47+
custom_css=custom_css,
48+
custom_js=custom_js,
49+
) as file:
1150
build_cmd = [
1251
executable,
1352
"-m",
@@ -26,6 +65,12 @@ def build(quiet: bool = False, debug: bool = False):
2665
process = Popen(build_cmd, stderr=stderr, stdout=stdout)
2766
while process.poll() is None:
2867
sleep(0.1)
68+
if process.returncode != 0:
69+
if pdb:
70+
import pdb
71+
72+
pdb.set_trace()
73+
raise Exit(process.returncode)
2974

3075

3176
def debug():

0 commit comments

Comments
 (0)