Skip to content

Commit f7dcb7b

Browse files
committed
Reorganize Reference section
1 parent 35840cb commit f7dcb7b

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

src/pulp_docs/mkdocs_macros.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
101101
this_src_dir = repo_sources / repo_or_pkg.subpackage_of / repo_or_pkg.name
102102

103103
# install and post-process
104-
_install_doc_files(this_src_dir, this_docs_dir, repo_or_pkg)
104+
_place_doc_files(this_src_dir, this_docs_dir, repo_or_pkg)
105105
if repo_or_pkg.type == "content":
106106
_generate_rest_api_page(this_docs_dir, repo_or_pkg.name, repo_or_pkg.title)
107107

@@ -122,7 +122,7 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
122122
return (repo_docs, repo_sources)
123123

124124

125-
def _install_doc_files(src_dir: Path, docs_dir: Path, repo: Repo):
125+
def _place_doc_files(src_dir: Path, docs_dir: Path, repo: Repo):
126126
"""Copy only doc-related files from src_dir to doc_dir"""
127127
log.info(f"Moving doc files:\nfrom '{src_dir}'\nto '{docs_dir}'")
128128

@@ -131,15 +131,18 @@ def _install_doc_files(src_dir: Path, docs_dir: Path, repo: Repo):
131131
except FileNotFoundError:
132132
Path(docs_dir / "docs").mkdir(parents=True)
133133
repo.status.has_staging_docs = False
134-
try:
135-
shutil.copy(src_dir / "CHANGELOG.md", docs_dir / "CHANGELOG.md")
136-
except FileNotFoundError:
137-
repo.status.has_changelog = False
138134

139-
try:
140-
shutil.copy(src_dir / "README.md", docs_dir / "README.md")
141-
except FileNotFoundError:
142-
repo.status.has_readme = False
135+
# Get CHANGELOG
136+
# TODO: remove reading .rst (plugins should provide markdown CHANGELOG)
137+
repo.status.has_changelog = False
138+
for changelog_name in ("CHANGELOG.md", "CHANGES.md", "CHANGES.rst"):
139+
changelog_path = Path(src_dir / changelog_name)
140+
if changelog_path.exists():
141+
reference_dir = Path(docs_dir / "docs/reference")
142+
reference_dir.mkdir(exist_ok=True)
143+
shutil.copy(changelog_path, reference_dir / "CHANGELOG.md")
144+
repo.status.has_changelog = True
145+
break
143146

144147

145148
def _generate_rest_api_page(docs_dir: Path, repo_name: str, repo_title: str):
@@ -243,8 +246,15 @@ def define_env(env):
243246

244247
log.info("[pulp-docs] Done with pulp-docs.")
245248
env.conf["pulp_repos"] = repos
249+
env.config["pulp_repos"] = repos
246250
env.conf["pulp_config"] = config
247251

252+
# Extra config
253+
@env.macro
254+
def get_repos(repo_type="content"):
255+
"Return repo names by type"
256+
return sorted(repos.get_repos(repo_types=[repo_type]), key=lambda x: x.title)
257+
248258

249259
def on_pre_page_macros(env):
250260
"""The mkdocs-macros hook just before an inidvidual page render."""

src/pulp_docs/navigation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,11 @@ def grouped_by_persona(tmpdir: Path, repos: Repos):
134134
]
135135
reference_section = [
136136
{"Overview": f.section_file("reference/index.md")},
137-
{"Repository Map": f.section_file("reference/01-repository-map.md")},
137+
{"Rest API": "pulp-docs/docs/rest_api.md"},
138138
{"Glossary": f.section_file("reference/02-glossary.md")},
139-
{"Repositories": f.repo_reference_grouping()},
139+
{"Pulpcore": f.section(Names.CORE, f.get_children, "pulpcore/docs/reference")},
140+
{"Plugins": f.repo_grouping("{repo}/docs/reference", repo_types=["content"])},
141+
{"Extra": f.repo_grouping("{repo}/docs/reference", repo_types=["other"])},
140142
]
141143

142144
# Main Section

src/pulp_docs/utils/aggregation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import typing as t
33
from pathlib import Path
4+
import re
45

56
from pulp_docs.constants import Names
67
from pulp_docs.repository import Repos

staging_docs/rest_api.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Rest API
2+
3+
The REST API reference for Pulp Plugins is generated using [ReDoc](https://redocly.com/redoc/) and are published in standalone pages:
4+
5+
<div class="grid cards" markdown>
6+
7+
{% for repo in get_repos() %}
8+
- <a href="https://docs.pulpproject.org/{{ repo.name }}/restapi.html" target="_blank">{{ repo.title }}</a>
9+
{% endfor %}
10+
11+
</div>

0 commit comments

Comments
 (0)