nbdev_mkdocs.mkdocs
nbdev_mkdocs_docs(root_path, refresh_quarto_settings=False)
¤
Prepare mkdocs documentation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_path |
str |
The root path of the project |
required |
refresh_quarto_settings |
bool |
Flag to refresh quarto yml file. This flag should be set to |
False |
Note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
Source code in nbdev_mkdocs/mkdocs.py
def nbdev_mkdocs_docs(root_path: str, refresh_quarto_settings: bool = False) -> None:
"""Prepare mkdocs documentation
Args:
root_path: The root path of the project
refresh_quarto_settings: Flag to refresh quarto yml file. This flag should be set to `True`
if this function is called directly without calling prepare.
!!! note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
"""
with set_cwd(root_path):
if refresh_quarto_settings:
refresh_quarto_yml()
_copy_cname_if_needed(root_path)
_copy_docs_overrides(root_path)
lib_name = get_value_from_config(root_path, "lib_name")
lib_path = get_value_from_config(root_path, "lib_path")
_build_summary(root_path, lib_path)
cmd = f"mkdocs build -f \"{(Path(root_path) / 'mkdocs' / 'mkdocs.yml').resolve()}\""
_sprun(cmd)
new(root_path)
¤
Initialize mkdocs project files
Creates mkdocs directory in the root_path directory and populates it with initial values. You should edit mkdocs.yml file to customize it if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_path |
str |
The path to the root of the project |
required |
Note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
Source code in nbdev_mkdocs/mkdocs.py
def new(root_path: str) -> None:
"""Initialize mkdocs project files
Creates **mkdocs** directory in the **root_path** directory and populates
it with initial values. You should edit mkdocs.yml file to customize it if
needed.
Args:
root_path: The path to the root of the project
!!! note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
"""
_create_mkdocs_dir(root_path)
_create_mkdocs_yaml(root_path)
_create_summary_template(root_path)
_replace_ghp_deploy_action(root_path)
_update_gitignore_file(root_path)
_generate_default_social_image_link(root_path)
prepare(root_path, no_test=False)
¤
Prepare mkdocs for serving
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_path |
str |
The root path of the project |
required |
no_test |
bool |
If set to False, the unit tests will be run, else they will be skipped |
False |
Note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
Source code in nbdev_mkdocs/mkdocs.py
def prepare(root_path: str, no_test: bool = False) -> None:
"""Prepare mkdocs for serving
Args:
root_path: The root path of the project
no_test: If set to False, the unit tests will be run, else they will be skipped
!!! note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
"""
with set_cwd(root_path):
if no_test:
nbdev_export.__wrapped__()
refresh_quarto_yml()
nbdev_readme.__wrapped__(chk_time=True)
else:
cmd = "nbdev_prepare"
_sprun(cmd)
nbdev_mkdocs_docs(root_path)
preview(root_path, port=None)
¤
Preview the mkdocs documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_path |
str |
The root path of the documentation. |
required |
port |
Optional[int] |
The port to serve the documentation on. |
None |
Note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
Source code in nbdev_mkdocs/mkdocs.py
def preview(root_path: str, port: Optional[int] = None) -> None:
"""Preview the mkdocs documentation.
Args:
root_path: The root path of the documentation.
port: The port to serve the documentation on.
!!! note
The above docstring is autogenerated by docstring-gen library (https://github.com/airtai/docstring-gen)
"""
with set_cwd(root_path):
prepare(root_path=root_path, no_test=True)
cmd = f"mkdocs serve -f {root_path}/mkdocs/mkdocs.yml -a 0.0.0.0"
if port:
cmd = cmd + f":{port}"
with subprocess.Popen( # nosec B603:subprocess_without_shell_equals_true
shlex.split(cmd),
stdout=subprocess.PIPE,
bufsize=1,
text=True,
universal_newlines=True,
) as p:
for line in p.stdout: # type: ignore
print(line, end="")
if p.returncode != 0:
typer.secho(
f"Command cmd='{cmd}' failed!",
err=True,
fg=typer.colors.RED,
)
raise typer.Exit(6)