diff --git a/src/pulp_docs/mkdocs_hooks.py b/src/pulp_docs/mkdocs_hooks.py index 16bf0d8..b693cef 100644 --- a/src/pulp_docs/mkdocs_hooks.py +++ b/src/pulp_docs/mkdocs_hooks.py @@ -3,9 +3,9 @@ See: https://www.mkdocs.org/user-guide/configuration/#hooks """ + import re from collections import defaultdict -from typing import Union from bs4 import BeautifulSoup as bs from mkdocs.structure.nav import Page, Section diff --git a/src/pulp_docs/mkdocs_macros.py b/src/pulp_docs/mkdocs_macros.py index 5456270..18b4b8e 100644 --- a/src/pulp_docs/mkdocs_macros.py +++ b/src/pulp_docs/mkdocs_macros.py @@ -198,14 +198,17 @@ def _place_doc_files(src_dir: Path, docs_dir: Path, repo: Repo, api_src_dir: Pat repo.status.has_staging_docs = False # Add index pages to User and Dev sections - for index_file in (docs_dir / "index.md", docs_dir / "docs/dev/index.md"): - with suppress(FileNotFoundError): - if not index_file.exists(): - index_file.write_text( - f"# Welcome to {repo.title}\n\nThis is a generated page. " - "See how to add a custom overview page for you plugin " - "[here](site:pulp-docs/docs/dev/guides/create-plugin-overviews/)." - ) + main_index = docs_dir / "docs/index.md" + dev_index = docs_dir / "docs/dev/index.md" + for index_file in (main_index, dev_index): + if not index_file.exists() and index_file.parent.exists(): + index_file.write_text( + f"# Welcome to {repo.title}\n\nThis is a generated page. " + "See how to add a custom overview page for you plugin " + "[here](site:pulp-docs/docs/dev/guides/create-plugin-overviews/)." + ) + # clean index url: pulpcore/docs/ -> pulpcore + shutil.move(main_index, main_index.parent.parent) # Setup section pages (for better urls) if repo.name == SECTION_REPO: diff --git a/src/pulp_docs/openapi.py b/src/pulp_docs/openapi.py index 69618c3..5ff7a64 100644 --- a/src/pulp_docs/openapi.py +++ b/src/pulp_docs/openapi.py @@ -1,6 +1,7 @@ """ Module for generating open-api json files for selected Pulp plugins. """ + import argparse import os import shutil @@ -95,7 +96,11 @@ def setup_venv(self, plugin: PulpPlugin): Creates virtualenv with plugin. """ create_venv_cmd = ("python", "-m", "venv", self.venv_path) - url = plugin.get_remote_url() if not plugin.is_subpackage else self.pulpcore.get_remote_url() + url = ( + plugin.get_remote_url() + if not plugin.is_subpackage + else self.pulpcore.get_remote_url() + ) install_cmd = ["pip", "install", f"git+{url}"] if self.dry_run is True: diff --git a/tests/test_openapi_generation.py b/tests/test_openapi_generation.py index d262041..f255c85 100644 --- a/tests/test_openapi_generation.py +++ b/tests/test_openapi_generation.py @@ -22,5 +22,5 @@ def test_openapi_generation(tmp_path: Path, monkeypatch): assert {"core-api.json", "rpm-api.json", "file-api.json"} == set(output_ls) for label, path in zip(output_labels, output_paths): - openapi_data= json.loads(path.read_text()) + openapi_data = json.loads(path.read_text()) assert label in openapi_data["info"]["x-pulp-app-versions"].keys()