From 949c010e1cd99da4a85b07f06abe19200cc535ed Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 19 Oct 2021 19:53:13 -0400 Subject: [PATCH] chore(python): include docs/UPGRADING.md in docs/index.rst if it exists (#1245) * chore(python): include docs/upgrading.rst in docs/index.rst if it exists * lint * use UPGRADING.md instead of upgrading.rst * add migration guide header, update link to doc * make spacing consistent --- synthtool/gcp/common.py | 4 ++++ synthtool/gcp/templates/python_library/docs/index.rst | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index d12859241..9083c7bb7 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -258,6 +258,10 @@ def py_library(self, **kwargs) -> Path: ): self.excludes += ["docs/index.rst"] + # Add kwargs to signal that UPGRADING.md should be included in docs/index.rst if it exists + if Path("docs/UPGRADING.md").exists(): + kwargs["include_uprading_doc"] = True + # Assume the python-docs-samples Dockerfile is used for samples by default if "custom_samples_dockerfile" not in kwargs: kwargs["custom_samples_dockerfile"] = False diff --git a/synthtool/gcp/templates/python_library/docs/index.rst b/synthtool/gcp/templates/python_library/docs/index.rst index 03b24c37f..1feedfe4a 100644 --- a/synthtool/gcp/templates/python_library/docs/index.rst +++ b/synthtool/gcp/templates/python_library/docs/index.rst @@ -14,16 +14,17 @@ API Reference {{ version }}/services {{ version }}/types {% endfor %} -{%- if migration_guide_version %} +{% if include_uprading_doc %} Migration Guide --------------- -See the guide below for instructions on migrating to the {{ migration_guide_version }} release of this library. +See the guide below for instructions on migrating to the latest version. .. toctree:: :maxdepth: 2 - UPGRADING +  UPGRADING + {% endif %} Changelog --------- @@ -31,6 +32,6 @@ Changelog For a list of all ``{{ metadata['repo']['distribution_name'] }}`` releases: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - changelog + changelog