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

Fix type aliases.

parent 48ec8b73
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,10 @@ from collections.abc import (
from .cache import Cache
from .puppet.strings import puppet_strings
from .format import format_class
from .format import (
format_class,
format_type_alias,
)
jinja = Environment(
loader=FileSystemLoader('templates'),
......@@ -255,11 +258,32 @@ def defined_types_index(defined_list: list) -> IndexCategory:
}
# def type_aliases_index(alias_list: list) -> IndexCategory:
# """Prepare type alias index list."""
# # TODO
#
#
def type_aliases_index(alias_list: list) -> IndexCategory:
"""Prepare type alias index list."""
groups = group_by(isprivate, alias_list)
lst: list[IndexSubcategory] = []
if publics := groups.get(False):
lst.append({
'title': 'Public Type Aliases',
'list': ({'name': i['name'],
'file': os.path.splitext(i['file'])[0]}
for i in publics),
})
if privates := groups.get(True):
lst.append({
'title': 'Private Type Aliases',
'list': ({'name': i['name'],
'file': os.path.splitext(i['file'])[0]}
for i in privates),
})
return {
'title': 'Type Aliases',
'list': lst,
}
# def resource_types_index(resource_list: list) -> IndexCategory:
# """
# Prepare resource type index list.
......@@ -280,13 +304,7 @@ def setup_module_index(base: str, module: ModuleEntry, data: dict[str, Any]) ->
data['data_types']
data['data_type_aliases']
# content.append({
# 'title': 'Type Aliases',
# 'list': [
# ]
# })
content.append(type_aliases_index(data['data_type_aliases']))
content.append(defined_types_index(data['defined_types']))
......@@ -318,7 +336,6 @@ def setup_module(base: str, module: ModuleEntry) -> None:
for puppet_class in data['puppet_classes'] + data['defined_types']:
# localpath = puppet_class['name'].split('::')
localpath, _ = os.path.splitext(puppet_class['file'])
# localdir, _ = os.path.splitext(puppet_class['name'])
dir = os.path.join(path, localpath)
pathlib.Path(dir).mkdir(parents=True, exist_ok=True)
# puppet_class['docstring']
......@@ -343,7 +360,19 @@ def setup_module(base: str, module: ModuleEntry) -> None:
# puppet_class['line']
for type_alias in data['data_type_aliases']:
...
localpath, _ = os.path.splitext(type_alias['file'])
dir = os.path.join(path, localpath)
pathlib.Path(dir).mkdir(parents=True, exist_ok=True)
with open(os.path.join(dir, 'source.pp.txt'), 'w') as f:
f.write(type_alias['alias_of'])
with open(os.path.join(dir, 'source.json'), 'w') as f:
json.dump(type_alias, f, indent=2)
template = jinja.get_template('code_page.html')
with open(os.path.join(dir, 'index.html'), 'w') as f:
f.write(template.render(content=format_type_alias(type_alias)))
os.system("cp -r static output")
......
......@@ -175,6 +175,11 @@ def handle_case_body(forms: list[dict[str, Any]],
return tag(ret)
# Hyperlinks for
# - qn
# - qr
# - var (except when it's the var declaration)
def parse(form: Any, indent: int, context: list[str]) -> Tag:
"""
Print everything from a puppet parse tree.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment