docs: add tags
This patch will add 'tags' top nav bar item to the mkdocs page. The tags
are collected from the metadata 'scope' list in each test.
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
diff --git a/mkdocs.yml b/mkdocs.yml
index 1900c83..ca4fe01 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -4,3 +4,7 @@
copyright: Linaro Ltd.
plugins:
- linaro-test-definitions
+ - tags
+ - exclude:
+ glob:
+ - plans/*
diff --git a/mkdocs_plugin/requirements.txt b/mkdocs_plugin/requirements.txt
index 0624163..c8a2de9 100644
--- a/mkdocs_plugin/requirements.txt
+++ b/mkdocs_plugin/requirements.txt
@@ -1,2 +1,4 @@
mkdocs-test-definitions-plugin
mdutils
+git+https://github.com/mwasilew/mkdocs-plugin-tags.git
+mkdocs-exclude
diff --git a/mkdocs_plugin/setup.py b/mkdocs_plugin/setup.py
index 6c04dff..f41441f 100644
--- a/mkdocs_plugin/setup.py
+++ b/mkdocs_plugin/setup.py
@@ -3,7 +3,7 @@
setup(
name='mkdocs-test-definitions-plugin',
- version='1.0.1',
+ version='1.1.0',
description='An MkDocs plugin that converts LAVA test definitions to documentation',
long_description='',
keywords='mkdocs python markdown wiki',
@@ -13,7 +13,7 @@
license='GPL',
python_requires='>=3.5',
install_requires=[
- 'mkdocs>=1'
+ 'mkdocs>=1.1'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
diff --git a/mkdocs_plugin/testdefinitionsmkdocs/__init__.py b/mkdocs_plugin/testdefinitionsmkdocs/__init__.py
index 2777f97..2ef5013 100644
--- a/mkdocs_plugin/testdefinitionsmkdocs/__init__.py
+++ b/mkdocs_plugin/testdefinitionsmkdocs/__init__.py
@@ -5,6 +5,7 @@
from mkdocs.plugins import BasePlugin
from mkdocs.structure.files import File
+from mdutils.fileutils.fileutils import MarkDownFile
class LinaroTestDefinitionsMkDocsPlugin(BasePlugin):
@@ -25,6 +26,14 @@
if "metadata" in content.keys():
metadata = content["metadata"]
mdFile = mdutils.MdUtils(file_name=tmp_filename, title=metadata['name'])
+ tags_section = "---\n"
+ tags_section += "title: %s\n" % metadata['name']
+ tags_section += "tags:\n"
+ scope_list = metadata.get("scope", None)
+ if scope_list is not None:
+ for item in scope_list:
+ tags_section += " - %s\n" % item
+ tags_section += "---\n"
mdFile.new_header(level=1, title="Test name: %s" % metadata['name'])
mdFile.new_header(level=1, title="Description")
mdFile.new_paragraph(metadata['description'])
@@ -34,7 +43,6 @@
for item in maintainer_list:
mdFile.new_line(" * %s" % item)
mdFile.new_header(level=1, title="Scope")
- scope_list = metadata.get("scope", None)
if scope_list is not None:
for item in scope_list:
mdFile.new_line(" * %s" % item)
@@ -43,8 +51,9 @@
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
- mdFile.create_md_file()
- return new_filename + ".md"
+ md_file = MarkDownFile(mdFile.file_name)
+ md_file.rewrite_all_file(data=tags_section + mdFile.title + mdFile.table_of_contents + mdFile.file_data_text)
+ return md_file.file_name
except yaml.YAMLError:
return None
except KeyError: