Skip to content

Commit c148b49

Browse files
authored
Add source-code flag to builds. (#13)
1 parent bc6bc19 commit c148b49

9 files changed

Lines changed: 58 additions & 6 deletions

File tree

.pyspelling.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ matrix:
3333
- open: '{%'
3434
content: '[\d\D]*'
3535
close: '%}'
36+
- open: ':::'
37+
content: '[\d\D]*'
38+
close: '\n'

docs/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,8 @@ plugins:
7676
literate-nav:
7777
nav_file: SUMMARY.md
7878
macros: {}
79+
mkdocstrings:
80+
default_handler: python
81+
handlers:
82+
python:
83+
paths: [src]

docs/en/section_one/page_two.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ Navigation should render at the bottom of the page; "BeeWare Docs Tools Demo
66
Section One" should be on the left, "Section Two" should be on the right.
77
The footer should be below the navigation links. This confirms the theme
88
configuration has been applied.
9+
10+
### Class reference documentation
11+
12+
The following should show the reference documentation for the `DocsTest`
13+
class, located in `docs_test.py`, in the `src/beeware_docs_tools`
14+
directory. This verifies that the source code directory symlinking is
15+
working properly.
16+
17+
::: beeware_docs_tools.docs_test.DocsTest

docs/spelling_wordlist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ reStructuredText
1212
subdirectories
1313
subdirectory
1414
symlinked
15+
symlinking
1516
Titlebar
1617
titlebar
1718
Weblate

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies = [
3030
"mkdocs-macros-plugin==1.3.9",
3131
"mkdocs-material==9.6.17",
3232
"mkdocs==1.6.1",
33+
"mkdocstrings-python==1.16.12",
3334
"pymdown-extensions==10.16.1",
3435
"pyspelling==2.10",
3536
"python-Levenshtein==0.27.1",

src/beeware_docs_tools/build_md_translations.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def parse_args() -> Namespace:
1616
parser.add_argument("language_code", nargs="*")
1717
parser.add_argument("--output", default=SOURCE_DIR / "_build" / "html")
1818
parser.add_argument("--build-with-errors", action="store_true")
19+
parser.add_argument("--source-code", action="append")
1920
args = parser.parse_args()
2021
for language_code in args.language_code:
2122
if not (
@@ -87,6 +88,17 @@ def main():
8788
) as config_temp:
8889
yaml.dump(config_file, config_temp)
8990

91+
# If source code directory or directories provided, symlink.
92+
if args.source_code:
93+
for directory in args.source_code:
94+
if "/" in directory:
95+
Path(temp_md_directory / directory).parent.mkdir(
96+
parents=True, exist_ok=True
97+
)
98+
(temp_md_directory / directory).symlink_to(
99+
SOURCE_DIR / directory, target_is_directory=True
100+
)
101+
90102
# Symlink overrides directory to the temp directory, so it is
91103
# available relative to the build.
92104
(temp_md_directory / "overrides").symlink_to(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class DocsTest:
2+
def __init__(self):
3+
"""This is the test class."""
4+
pass
5+
6+
def attribute(self):
7+
"""This is a test attribute."""
8+
pass

src/beeware_docs_tools/live_serve_en.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def parse_args() -> Namespace:
1919
parser = ArgumentParser()
2020
parser.add_argument("watch_directory", nargs="*")
2121
parser.add_argument("--build-with-errors", action="store_true")
22+
parser.add_argument("--source-code", action="append")
2223
args = parser.parse_args()
2324

2425
return args
@@ -53,9 +54,21 @@ def serve_docs(config_location) -> None:
5354

5455

5556
def main():
57+
args = parse_args()
58+
5659
with TemporaryDirectory() as temp_md_directory:
5760
temp_md_directory = Path(temp_md_directory)
5861

62+
if args.source_code:
63+
for directory in args.source_code:
64+
if "/" in directory:
65+
Path(temp_md_directory / directory).parent.mkdir(
66+
parents=True, exist_ok=True
67+
)
68+
(temp_md_directory / directory).symlink_to(
69+
SOURCE_DIR / directory, target_is_directory=True
70+
)
71+
5972
config_file = yaml.load(
6073
open(SOURCE_DIR / "docs" / "config.yml"), Loader=yaml.SafeLoader
6174
)

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ skip_install = true
1414
deps =
1515
-r {tox_root}/requirements.docs.txt
1616
commands:
17-
!lint-!all-!translate-!live-!en-!fr-!de : build_md_translations {posargs} en
17+
!lint-!all-!translate-!live-!en-!fr-!de : build_md_translations {posargs} --source-code=src en
1818
translate : md2po --input docs{/}en --output {[docs]templates_dir} --pot --duplicates=merge
1919
translate : build_po_translations fr de
2020
lint : markdown-checker --dir {[docs]docs_dir} --func check_broken_urls
2121
lint : pyspelling
22-
live : live_serve_en {posargs} src
23-
all : build_md_translations {posargs} en fr de
24-
en : build_md_translations {posargs} en
25-
fr : build_md_translations {posargs} fr
26-
de : build_md_translations {posargs} de
22+
live : live_serve_en {posargs} src --source-code=src
23+
all : build_md_translations {posargs} --source-code=src en fr de
24+
en : build_md_translations {posargs} --source-code=src en
25+
fr : build_md_translations {posargs} --source-code=src fr
26+
de : build_md_translations {posargs} --source-code=src de

0 commit comments

Comments
 (0)