Skip to content

Commit 29149c0

Browse files
authored
Include dir only if present. (#237)
1 parent 6e967a4 commit 29149c0

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/beeware_docs_tools/md_tempdir.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,22 @@ def save_config(project_path, temp_md_path, config, language="en"):
6868

6969
base_path = config["markdown_extensions"]["pymdownx.snippets"].get("base_path", [])
7070

71-
contribution_root = config["extra"].get(
72-
"contribution_guide_root", "how-to/contribute"
73-
)
71+
contribution_root = config["extra"].get("contribution_guide_root")
7472

7573
if language != "en":
7674
shared_content_path = temp_md_path.resolve() / f"shared_content/{language}"
77-
local_docs_path = temp_md_path.resolve() / language / contribution_root
75+
if contribution_root:
76+
local_docs_path = temp_md_path.resolve() / language / contribution_root
7877
else:
7978
shared_content_path = (Path(__file__).parent / "shared_content/en").resolve()
80-
local_docs_path = (project_path / "docs/en" / contribution_root).resolve()
79+
if contribution_root:
80+
local_docs_path = (project_path / "docs/en" / contribution_root).resolve()
8181

8282
base_path.append(str(shared_content_path))
8383
config["markdown_extensions"]["pymdownx.snippets"]["base_path"] = base_path
84-
config["plugins"]["macros"]["include_dir"] = [
85-
str(shared_content_path),
86-
str(local_docs_path),
87-
]
84+
config["plugins"]["macros"]["include_dir"] = [str(shared_content_path)]
85+
if contribution_root:
86+
config["plugins"]["macros"]["include_dir"].append(str(local_docs_path))
8887

8988
with (temp_md_path / "config.yml").open("w", encoding="utf-8") as config_f:
9089
yaml.dump(config, config_f)

0 commit comments

Comments
 (0)