From 37d9e25fe891c1c72bf7dfc9ebedc3d5a30aa4cc Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Tue, 23 Apr 2019 12:58:22 -0700 Subject: [PATCH 1/2] feat: provide 'title' in .readme-partials.yaml to override the default --- synthtool/gcp/common.py | 3 ++- synthtool/gcp/templates/node_library/README.md | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index 6734f7e64..bbbbe756c 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -142,8 +142,9 @@ def _load_partials(self, metadata: Dict): hand-crafted artisinal markdown can be provided in a .readme-partials.yml. The following fields are currently supported: - introduction: a more thorough introduction than metadata["description"]. body: custom body to include in the usage section of the document. + introduction: a more thorough introduction than metadata["description"]. + title: provide markdown to use as a custom title. """ cwd_path = Path(os.getcwd()) partials_file = None diff --git a/synthtool/gcp/templates/node_library/README.md b/synthtool/gcp/templates/node_library/README.md index 48d2ea447..92fa8e70e 100644 --- a/synthtool/gcp/templates/node_library/README.md +++ b/synthtool/gcp/templates/node_library/README.md @@ -2,7 +2,11 @@ [//]: # "To regenerate it, use `python -m synthtool`." Google Cloud Platform logo +{% if 'partials' in metadata and metadata['partials']['title'] -%} +{{ metadata['partials']['title'] }} +{% else -%} # [{{ metadata['repo']['name_pretty'] }}: {{ metadata['repo']['language']|language_pretty }} Client](https://github.com/{{ metadata['repo']['repo'] }}) +{%- endif %} {{ metadata['repo']['release_level']|release_quality_badge }} [![npm version](https://img.shields.io/npm/v/{{ metadata['name'] }}.svg)](https://www.npmjs.org/package/{{ metadata['name'] }}) @@ -14,7 +18,7 @@ | This library is **deprecated**. {{ metadata['deprecated'] }} | {% endif %} -{% if metadata['partials'] and metadata['partials']['introduction'] %} +{% if 'partials' in metadata and metadata['partials']['introduction'] %} {{ metadata['partials']['introduction'] }} {% else %} {{ metadata['description'] }} @@ -63,7 +67,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. ```{{ metadata['repo']['language']|syntax_highlighter }} {{ metadata['quickstart'] }} ``` -{% endif %}{% if metadata['partials'] and metadata['partials']['body'] %}{{ metadata['partials']['body'] }}{% endif %} +{% endif %}{% if 'partials' in metadata and metadata['partials']['body'] %}{{ metadata['partials']['body'] }}{% endif %} {% if metadata['samples']|length %} ## Samples From 0e4011edd702b88bae67e5ebf756d6beeead714c Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Tue, 23 Apr 2019 13:09:32 -0700 Subject: [PATCH 2/2] also use alternate title in samples --- synthtool/gcp/templates/node_library/samples/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/synthtool/gcp/templates/node_library/samples/README.md b/synthtool/gcp/templates/node_library/samples/README.md index 971e3e120..085cb8b58 100644 --- a/synthtool/gcp/templates/node_library/samples/README.md +++ b/synthtool/gcp/templates/node_library/samples/README.md @@ -2,7 +2,11 @@ [//]: # "To regenerate it, use `python -m synthtool`." Google Cloud Platform logo +{% if 'partials' in metadata and metadata['partials']['title'] -%} +{{ metadata['partials']['title'] }} Samples +{% else -%} # [{{ metadata['repo']['name_pretty'] }}: {{ metadata['repo']['language']|language_pretty }} Samples](https://github.com/{{ metadata['repo']['repo'] }}) +{%- endif %} [![Open in Cloud Shell][shell_img]][shell_link]