@@ -101,7 +101,7 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
101
101
this_src_dir = repo_sources / repo_or_pkg .subpackage_of / repo_or_pkg .name
102
102
103
103
# 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 )
105
105
if repo_or_pkg .type == "content" :
106
106
_generate_rest_api_page (this_docs_dir , repo_or_pkg .name , repo_or_pkg .title )
107
107
@@ -122,7 +122,7 @@ def prepare_repositories(TMPDIR: Path, repos: Repos, config: Config):
122
122
return (repo_docs , repo_sources )
123
123
124
124
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 ):
126
126
"""Copy only doc-related files from src_dir to doc_dir"""
127
127
log .info (f"Moving doc files:\n from '{ src_dir } '\n to '{ docs_dir } '" )
128
128
@@ -131,15 +131,18 @@ def _install_doc_files(src_dir: Path, docs_dir: Path, repo: Repo):
131
131
except FileNotFoundError :
132
132
Path (docs_dir / "docs" ).mkdir (parents = True )
133
133
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
138
134
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
143
146
144
147
145
148
def _generate_rest_api_page (docs_dir : Path , repo_name : str , repo_title : str ):
@@ -243,8 +246,15 @@ def define_env(env):
243
246
244
247
log .info ("[pulp-docs] Done with pulp-docs." )
245
248
env .conf ["pulp_repos" ] = repos
249
+ env .config ["pulp_repos" ] = repos
246
250
env .conf ["pulp_config" ] = config
247
251
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
+
248
258
249
259
def on_pre_page_macros (env ):
250
260
"""The mkdocs-macros hook just before an inidvidual page render."""
0 commit comments