Skip to content

Commit

Permalink
Add the tkn reference to the CLI docs
Browse files Browse the repository at this point in the history
Add the doc/cmd folder to add the tkn reference docs to the CLI
documentation. Add support for defaulting page title and link
title to the filename, if not set, which works OK for tkn.

Fixes #118

Signed-off-by: Andrea Frittoli <[email protected]>
  • Loading branch information
afrittoli committed Nov 9, 2020
1 parent a5ed52e commit bd2b411
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions sync/config/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ tags:
docs:
index: README.md
include: ['*.md']
docs/cmd:
index: tkn.md
include: ['*.md']
target: 'cmd'
header:
description: The `tkn` CLI reference
- name: v0.12.1
# The name to display on tekton.dev.
# helper.py will use this value in the version switcher and other places.
Expand Down
6 changes: 6 additions & 0 deletions sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ def transform_doc(doc, source_folder, target, target_folder, header,
target = os.path.join(site_target_folder, target)
with open(target, 'w+') as target_doc:
# If there is an header configured, write it (in YAML)
# If there is no title set, use the filename
# If there is not linkTitle set, use the title
if header:
filename, _ = os.path.splitext(doc.name)
header['title'] = header.get('title', filename)
header['linkTitle'] = header.get('linkTitle',
header.get('title', filename))
target_doc.write(YAML_SEPARATOR)
YAML().dump(header, target_doc)
target_doc.write(YAML_SEPARATOR)
Expand Down
7 changes: 6 additions & 1 deletion sync/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def test_transform_doc(self):
"test1: abc\n"
"test2: 1\n"
"test3: true\n"
"title: content\n"
"linkTitle: content\n"
"---\n"
)
actual_result = transform_doc(
Expand Down Expand Up @@ -345,9 +347,12 @@ def test_transform_docs(self):
"---\n"
"test1: abc\n"
"weight: {weight}\n"
"title: {name}\n"
"linkTitle: {name}\n"
"---\n"
)
expected_contents = [template.format(weight=idx) for idx in range(2)]
expected_contents = [template.format(weight=idx, name=name)
for idx, name in zip(range(2), ['content', 'test'])]
actual_results = transform_docs(
self.gitrepo, self.tagname, folders_config, site_dir,
'/doc/test', 'http://test.com/test/tree')
Expand Down

0 comments on commit bd2b411

Please sign in to comment.