@@ -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:\n from '{ src_dir } '\n to '{ 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
145148def _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
249259def on_pre_page_macros (env ):
250260 """The mkdocs-macros hook just before an inidvidual page render."""
0 commit comments