Skip to content

Commit

Permalink
Fix plugin index pages not being shown
Browse files Browse the repository at this point in the history
Closes: #63
  • Loading branch information
pedro-psb committed Jul 5, 2024
1 parent a6d5f24 commit 1aa44f0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/pulp_docs/mkdocs_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions src/pulp_docs/mkdocs_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion src/pulp_docs/openapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module for generating open-api json files for selected Pulp plugins.
"""

import argparse
import os
import shutil
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_openapi_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 1aa44f0

Please sign in to comment.