-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcore.py
More file actions
28 lines (24 loc) · 844 Bytes
/
core.py
File metadata and controls
28 lines (24 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""MkDocs project setup and configuration."""
from usethis._config import usethis_config
from usethis._console import tick_print
from usethis._integrations.project.name import get_project_name
def add_docs_dir() -> None:
"""Create the `docs` directory and a `docs/index.md` file if they do not exist."""
docs_dir = usethis_config.cpd() / "docs"
if not docs_dir.exists():
tick_print("Creating '/docs'.")
docs_dir.mkdir()
write_index = True
elif not (docs_dir / "index.md").exists():
tick_print("Writing '/docs/index.md'.")
write_index = True
else:
write_index = False
if write_index:
(docs_dir / "index.md").write_text(
f"""\
# {get_project_name()}
Welcome to the documentation for {get_project_name()}.
""",
encoding="utf-8",
)