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
8e6e230a
Commit
8e6e230a
authored
Jul 3, 2023
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Set up logging.
parent
b1494d78
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
muppet/__main__.py
+15
-0
15 additions, 0 deletions
muppet/__main__.py
muppet/output.py
+11
-0
11 additions, 0 deletions
muppet/output.py
muppet/puppet/parser.py
+4
-0
4 additions, 0 deletions
muppet/puppet/parser.py
with
30 additions
and
0 deletions
muppet/__main__.py
+
15
−
0
View file @
8e6e230a
...
...
@@ -3,12 +3,26 @@
import
argparse
import
pathlib
import
os
import
logging
import
colorlog
from
.cache
import
Cache
from
.gather
import
get_module
,
get_modules
,
ModuleEntry
from
.output
import
setup_index
,
setup_module
logger
=
logging
.
getLogger
(
'
muppet
'
)
logger
.
setLevel
(
logging
.
DEBUG
)
ch
=
colorlog
.
StreamHandler
()
ch
.
setLevel
(
logging
.
INFO
)
# formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
formatter
=
colorlog
.
ColoredFormatter
(
'
%(log_color)s%(name)s - %(levelname)s - %(message)s
'
)
ch
.
setFormatter
(
formatter
)
logger
.
addHandler
(
ch
)
def
__main
()
->
None
:
parser
=
argparse
.
ArgumentParser
(
prog
=
'
puppet-doc configure
'
,
...
...
@@ -45,6 +59,7 @@ def __main() -> None:
for
module
in
modules
:
# print(module)
logger
.
info
(
'
Handling %s
'
,
module
.
name
)
setup_module
(
'
output
'
,
module
,
path_base
=
args
.
path_base
)
os
.
system
(
'
make -C static-src --silent install-full PREFIX=$PWD/output
'
)
...
...
This diff is collapsed.
Click to expand it.
muppet/output.py
+
11
−
0
View file @
8e6e230a
...
...
@@ -33,6 +33,7 @@ from .puppet.strings import (
DataTypeAlias
,
PuppetClass
,
)
import
logging
from
.breadcrumbs
import
breadcrumbs
from
.syntax_highlight
import
highlight
...
...
@@ -40,6 +41,9 @@ from dataclasses import dataclass, field
from
.
import
templates
logger
=
logging
.
getLogger
(
__name__
)
# TODO replace 'output' with base, or put this somewhere else
pathlib
.
Path
(
'
output
'
).
mkdir
(
exist_ok
=
True
)
jinja
=
Environment
(
...
...
@@ -496,6 +500,7 @@ def setup_module(base: str, module: ModuleEntry, *, path_base: str) -> None:
data
=
module
.
strings_output
for
puppet_class
in
data
.
puppet_classes
+
data
.
defined_types
:
logger
.
debug
(
'
Formamting %s
'
,
puppet_class
.
name
)
# localpath = puppet_class['name'].split('::')
localpath
,
_
=
os
.
path
.
splitext
(
puppet_class
.
file
)
dir
=
os
.
path
.
join
(
path
,
localpath
)
...
...
@@ -552,6 +557,8 @@ def setup_module(base: str, module: ModuleEntry, *, path_base: str) -> None:
# puppet_class['line']
for
type_alias
in
data
.
data_type_aliases
:
logger
.
debug
(
'
Formamting %s
'
,
type_alias
.
name
)
localpath
,
_
=
os
.
path
.
splitext
(
type_alias
.
file
)
dir
=
os
.
path
.
join
(
path
,
localpath
)
pathlib
.
Path
(
dir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
...
...
@@ -576,6 +583,8 @@ def setup_module(base: str, module: ModuleEntry, *, path_base: str) -> None:
files
:
dict
[
str
,
str
]
=
{}
for
file
in
module
.
doc_files
:
logger
.
debug
(
'
Formamting %s
'
,
file
)
basename
=
os
.
path
.
basename
(
file
)
if
basename
==
'
REFERENCE.md
'
:
with
open
(
file
)
as
f
:
...
...
@@ -588,6 +597,8 @@ def setup_module(base: str, module: ModuleEntry, *, path_base: str) -> None:
doc_files
:
dict
[
str
,
str
]
=
{}
for
filename
,
filepath
in
files
.
items
():
logger
.
debug
(
'
Formamting %s
'
,
filename
)
name
,
_
=
os
.
path
.
splitext
(
filename
)
with
open
(
filepath
)
as
f
:
raw_content
=
f
.
read
()
...
...
This diff is collapsed.
Click to expand it.
muppet/puppet/parser.py
+
4
−
0
View file @
8e6e230a
...
...
@@ -11,6 +11,10 @@ import json
from
typing
import
Any
,
TypeAlias
,
Union
from
..cache
import
Cache
import
logging
logger
=
logging
.
getLogger
(
__name__
)
# TODO cache path
...
...
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