Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
muppet-strings
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
muppet-strings
Commits
d39cf35c
Commit
d39cf35c
authored
May 29, 2023
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Fix type aliases.
parent
48ec8b73
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
muppet/__main__.py
+44
-15
44 additions, 15 deletions
muppet/__main__.py
muppet/format.py
+5
-0
5 additions, 0 deletions
muppet/format.py
with
49 additions
and
15 deletions
muppet/__main__.py
+
44
−
15
View file @
d39cf35c
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
muppet/format.py
+
5
−
0
View file @
d39cf35c
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment