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
e62d89d3
Commit
e62d89d3
authored
Jun 3, 2023
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Add summary to main index page.
parent
89d10b2a
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
+19
-7
19 additions, 7 deletions
muppet/__main__.py
templates/index.html
+7
-1
7 additions, 1 deletion
templates/index.html
with
26 additions
and
8 deletions
muppet/__main__.py
+
19
−
7
View file @
e62d89d3
...
@@ -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
()
This diff is collapsed.
Click to expand it.
templates/index.html
+
7
−
1
View file @
e62d89d3
...
@@ -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') %}
—
{{ module.metadata['summary'] }}
{%- endif -%}
</li>
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
...
...
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