Skip to content
Snippets Groups Projects
Commit e62d89d3 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Add summary to main index page.

parent 89d10b2a
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,7 @@ class ModuleEntry: ...@@ -67,6 +67,7 @@ class ModuleEntry:
name: str name: str
path: str path: str
strings_output: bytes strings_output: bytes
metadata: dict[str, Any]
def file(self, path: str) -> str: def file(self, path: str) -> str:
"""Return the absolute path of a path inside the module.""" """Return the absolute path of a path inside the module."""
...@@ -125,7 +126,13 @@ def get_modules(dir: str) -> list[ModuleEntry]: ...@@ -125,7 +126,13 @@ def get_modules(dir: str) -> list[ModuleEntry]:
path = os.path.join(env, entry) path = os.path.join(env, entry)
strings_data = get_puppet_strings(path) strings_data = get_puppet_strings(path)
modules.append(ModuleEntry(name, path, strings_data)) try:
with open(os.path.join(path, 'metadata.json')) as f:
metadata = json.load(f)
except FileNotFoundError:
metadata = {}
modules.append(ModuleEntry(name, path, strings_data, metadata))
return modules return modules
...@@ -171,7 +178,7 @@ def isprivate(entry: dict[str, Any]) -> bool: ...@@ -171,7 +178,7 @@ def isprivate(entry: dict[str, Any]) -> bool:
return False return False
def setup_index(base: str) -> None: def setup_index(base: str, modules: list[ModuleEntry]) -> None:
"""Create the main index.html file.""" """Create the main index.html file."""
template = jinja.get_template('index.html') template = jinja.get_template('index.html')
with open(os.path.join(base, 'index.html'), 'w') as f: with open(os.path.join(base, 'index.html'), 'w') as f:
...@@ -403,9 +410,14 @@ def setup_module(base: str, module: ModuleEntry) -> None: ...@@ -403,9 +410,14 @@ def setup_module(base: str, module: ModuleEntry) -> None:
# data['resource_types'] # data['resource_types']
def __main() -> None:
modules = get_modules(env) modules = get_modules(env)
setup_index('output', modules)
setup_index('output')
for module in modules: for module in modules:
# print(module) # print(module)
setup_module('output', module) setup_module('output', module)
if __name__ == '__main__':
__main()
...@@ -17,9 +17,15 @@ ...@@ -17,9 +17,15 @@
<ul> <ul>
{% for module in modules %} {% for module in modules %}
<li> <li>
<a href="/{{ module.name }}" {%- if module.metadata.get('name') -%}
{{ module.metadata['name'].split('-')[0] }}/
{%- endif -%}
<a href="{{ module.name }}"
class="{{ 'error' if module.strings_output == None }}" class="{{ 'error' if module.strings_output == None }}"
>{{ module.name }}</a> >{{ module.name }}</a>
{%- if module.metadata.get('summary') %}
&mdash; {{ module.metadata['summary'] }}
{%- endif -%}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment