This commit is contained in:
egarette@silique.fr 2026-01-07 08:36:06 +01:00
parent abf29b2a3c
commit 11ebbb8dc5
252 changed files with 393 additions and 308 deletions

View file

@ -9,7 +9,7 @@ from bs4 import BeautifulSoup
from rougail import Rougail
from rougail.config import get_rougail_config
from rougail.output_console import RougailOutputConsole
from rougail.output_display import RougailOutputDisplay
from rougail.user_data_yaml import RougailUserDataYaml
from rougail.output_doc import RougailOutputDoc
@ -50,7 +50,8 @@ if __name__ == "__main__":
inventory = RougailOutputDoc(config, rougailconfig=rougailconfig)
inventory.load_formatter()
inv_formatter = inventory.formatter
rougailconfig['step.output'] = 'console'
rougailconfig['step.output'] = 'display'
rougailconfig['display.console.max_width'] = 80
summary = Path('summary_before.md')
if summary.is_file():
with summary.open('r') as sfh:
@ -78,7 +79,10 @@ if __name__ == "__main__":
doc += '\n' + inv_formatter.title('Structure', 2) + '\n\n'
with tree.open() as fh:
soup = BeautifulSoup(fh.read(), features="lxml")
doc += str(soup.find('p')) + "\n\n"
tree_content = str(soup.find('p'))
doc += tree_content + "\n\n"
with tree.open("w") as fh:
fh.write(tree_content)
for f in Path(".").iterdir():
if f.name.startswith('DISPLAY_'):
filename = f.name[8:]
@ -115,7 +119,7 @@ if __name__ == "__main__":
doc += inv_doc
if previous.is_file():
rougailconfig["doc.contents"] = ["changelog"]
rougailconfig["doc.previous_json_file"] = str(previous)
rougailconfig["doc.changelog.previous_json_file"] = str(previous)
inv_doc = inventory.run()[1]
if inv_doc:
doc += inv_formatter.title("Let's generate the changelog", 3)
@ -130,7 +134,7 @@ if __name__ == "__main__":
with previous.open('w') as fh:
dump(loads(data), fh)
#
rougailconfig['step.output'] = 'console'
rougailconfig['step.output'] = 'display'
config = Path('config')
if config.is_dir():
doc += inv_formatter.title('User datas', 2)
@ -153,8 +157,9 @@ if __name__ == "__main__":
rougailconfig['yaml.filename'] = [str(filename)]
data = RougailUserDataYaml(tiramisu_config, rougailconfig=rougailconfig)
ret = data.run()
errors = rougail.user_datas(ret)
export = RougailOutputConsole(tiramisu_config,
errors = rougail.user_data(ret)
rougailconfig['display.output_format'] = "console"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=rougailconfig,
user_data_errors=errors['errors'],
user_data_warnings=errors['warnings'],
@ -167,12 +172,19 @@ if __name__ == "__main__":
fh.write(cmd)
doc += f"```shell\n{cmd}\n```\n"
conv_data = '<pre>' + conv.convert(console, full=False) + "</pre>\n"
doc += conv_data
with open(dirname / 'output_ro.html', 'w') as fh_output:
fh_output.write(conv_data)
rougailconfig['display.output_format'] = "github"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=rougailconfig,
user_data_errors=errors['errors'],
user_data_warnings=errors['warnings'],
)
doc += export.run()[1]
if (dirname / 'invalid').is_file():
errors2 = rougail.user_datas(ret, invalid_user_datas_error=True)
export = RougailOutputConsole(tiramisu_config,
errors2 = rougail.user_data(ret, invalid_user_data_error=True)
rougailconfig['display.output_format'] = "console"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=rougailconfig,
user_data_errors=errors2['errors'],
user_data_warnings=errors2['warnings'],
@ -180,20 +192,27 @@ if __name__ == "__main__":
console = export.run()[1]
conv = Ansi2HTMLConverter(inline=True)
doc += inv_formatter.title('Output when invalid user datas is an error', 4)
cmd2 = cmd + " --cli.invalid_user_datas_error"
cmd2 = cmd + " --cli.invalid_user_data_error"
with (dirname / "cmd_invalid.txt").open("w") as fh:
fh.write(cmd2)
doc += f"```shell\n{cmd2}\n```\n"
conv_data = '<pre>' + conv.convert(console, full=False) + "</pre>\n"
doc += conv_data
with open(dirname / 'output_invalid.html', 'w') as fh_output:
fh_output.write(conv_data)
rougailconfig['display.output_format'] = "github"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=rougailconfig,
user_data_errors=errors2['errors'],
user_data_warnings=errors2['warnings'],
)
doc += export.run()[1]
if (dirname / 'read_write').is_file():
trougailconfig = rougailconfig.copy()
trougailconfig["console.mandatory"] = False
trougailconfig["display.mandatory"] = False
tiramisu_config.property.read_write()
errors2 = rougail.user_datas(ret, invalid_user_datas_error=True)
export = RougailOutputConsole(tiramisu_config,
errors2 = rougail.user_data(ret, invalid_user_data_error=True)
rougailconfig['display.output_format'] = "console"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=trougailconfig,
user_data_errors=errors2['errors'],
user_data_warnings=errors2['warnings'],
@ -206,9 +225,15 @@ if __name__ == "__main__":
fh.write(cmd2)
doc += f"```shell\n{cmd2}\n```\n"
conv_data = '<pre>' + conv.convert(console, full=False) + "</pre>\n"
doc += conv_data
with open(dirname / 'output_rw.html', 'w') as fh_output:
fh_output.write(conv_data)
trougailconfig['display.output_format'] = "github"
export = RougailOutputDisplay(tiramisu_config,
rougailconfig=trougailconfig,
user_data_errors=errors2['errors'],
user_data_warnings=errors2['warnings'],
)
doc += export.run()[1]
tiramisu_config.property.read_only()
#
summary = Path('summary_after.md')

View file

@ -62,7 +62,7 @@ for i in $(ls -d "examples"/* | sort); do
echo "$num"
commit_id="v${VERSION}_$num"
title=$(head -n 1 $i/README.md)
summary="[tutorial $commit_id)] $title"
summary="[tutorial $commit_id] $title"
if [ -f $i/URL ]; then
base_url_doc=$(cat $i/URL)
fi

View file

@ -1 +0,0 @@
Making a structure file

View file

@ -1 +0,0 @@
Let's create our first "variable"

View file

@ -1,9 +1 @@
Describe the variable
We can add a description to this first variable.
This information is useful for:
- documentation
- error message
- help user to known which value to set to this variable (for example with [the user data plugin Questionary](https://forge.cloud.silique.fr/stove/rougail-user-data-questionary)).

View file

@ -1,7 +1 @@
Set a default value
Now we can define the default value of this variable.
If the user doesn't touch this variable's value, the value is "No proxy"
As user intervention is no more required, so the variable change it's default mode too (from "basic" to "standard").

View file

@ -1,7 +0,0 @@
Limits the possible values for the variable
"Foo" should not be an option to the "proxy_mode" variable.
Now the "proxy_mode" type is "choice", that means that there is a list of available values that can be selected.
We say that the "proxy_mode" variable is constrained (by choices): this variable accept, in fact, only a list of choices.

View file

@ -1 +1 @@
Creating a new family
A variable with a list of possible values

View file

@ -1 +0,0 @@
Group variables inside "families"

1
examples/010/TITLE.md Normal file
View file

@ -0,0 +1 @@
A variable with a list of possible values

View file

@ -1 +0,0 @@
https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/proxymode.html

View file

@ -1,8 +0,0 @@
%YAML 1.2
---
version: 1.1
manual:
description: Manual proxy configuration
type: family
...

View file

@ -1,8 +0,0 @@
Or a sub family
Inside a family, we can have variables or families.
The "type" for family "manual" became unecessary because container an other family, so it's not a variable.
The description can now be has family comment.
In disabled attribute, it's better tu use relative path (we will see the reason in an other slide).

View file

@ -1,10 +0,0 @@
%YAML 1.2
---
version: 1.1
manual: # Manual proxy configuration
http_proxy:
description: HTTP Proxy
type: family
...

View file

@ -1 +0,0 @@
Putting a variable inside of a family or a sub family

View file

@ -1,4 +0,0 @@
---
manual:
http_proxy:
address: example.net

View file

@ -1,10 +0,0 @@
%YAML 1.2
---
version: 1.1
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address: # HTTP address
...

View file

@ -1 +1 @@
A variable with type "domainname"
Creating a new family

View file

@ -1 +1 @@
Constrainte the value of a variable with it's type
Group variables inside "families"

View file

@ -1 +1 @@
https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/disabled.html
https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/proxymode.html

View file

@ -1,4 +0,0 @@
---
manual:
http_proxy:
address: 192.168.0.1

View file

@ -1,4 +0,0 @@
---
manual:
http_proxy:
address: not a valid domain name

View file

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

View file

@ -2,11 +2,7 @@
---
version: 1.1
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
manual:
description: Manual proxy configuration
type: family
...

View file

@ -1 +1,8 @@
A variable with type's parameters
Or a sub family
Inside a family, we can have variables or families.
The "type" for family "manual" became unecessary because container an other family, so it's not a variable.
The description can now be has family comment.
In disabled attribute, it's better tu use relative path (we will see the reason in an other slide).

View file

@ -1 +0,0 @@
../020/config

View file

@ -4,11 +4,7 @@ version: 1.1
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
http_proxy:
description: HTTP Proxy
type: family
...

View file

@ -1 +1 @@
A variable with type "port"
Putting a variable inside of a family or a sub family

View file

@ -1,5 +1 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net

View file

@ -1,6 +1,4 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net
port: 3128

View file

@ -1,6 +1,5 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net
port: 100000
port: 3128

View file

@ -6,14 +6,5 @@ manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
address: # HTTP address
...

View file

@ -1 +0,0 @@
A variable with type "boolean"

View file

@ -1,4 +0,0 @@
---
manual:
http_proxy:
address: example.net

View file

@ -1,5 +0,0 @@
---
manual:
http_proxy:
address: example.net
use_for_https: false

View file

@ -1,8 +0,0 @@
%YAML 1.2
---
version: 1.1
manual:
use_for_https: true # Also use this proxy for HTTPS
...

View file

@ -1 +1 @@
A disabled family
A variable with type "domainname"

View file

@ -1 +1 @@
Define access to variable or family
Constrainte the value of a variable with it's type

1
examples/030/URL Normal file
View file

@ -0,0 +1 @@
https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/disabled.html

View file

@ -1 +1,4 @@
---
manual:
http_proxy:
address: example.net

View file

@ -1,7 +1,4 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
address: 192.168.0.1

View file

@ -0,0 +1,4 @@
---
manual:
http_proxy:
address: not a valid domain name.com

View file

@ -2,20 +2,11 @@
---
version: 1.1
manual:
description: Manual proxy configuration
disabled: true
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
...

View file

@ -1 +1 @@
A conditional disabled family
A variable with type's parameters

View file

@ -1 +1,4 @@
---
manual:
http_proxy:
address: example.net

View file

@ -1,7 +1,4 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
address: 192.168.0.1

View file

@ -0,0 +1,4 @@
---
manual:
http_proxy:
address: not a valid domain name.com

View file

@ -2,11 +2,7 @@
---
version: 1.1
manual:
description: Manual proxy configuration
disabled:
variable: _.proxy_mode
when_not: Manual proxy configuration
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
@ -15,9 +11,4 @@ manual:
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
...

View file

@ -1 +1 @@
Copy HTTP manual proxy to HTTPS manual proxy
A variable with type "port"

View file

@ -1,4 +1,5 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net

View file

@ -1,4 +1,5 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net

View file

@ -0,0 +1,6 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: example.net
port: 100000

View file

@ -0,0 +1,19 @@
%YAML 1.2
---
version: 1.1
manual: # Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
...

View file

@ -1 +1 @@
A conditional hidden family
A variable with type "boolean"

View file

@ -1,9 +1,4 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
https_proxy:
address: https.proxy.net
address: example.net

View file

@ -1,7 +1,5 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: true
address: example.net
use_for_https: false

View file

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View file

@ -5,20 +5,4 @@ version: 1.1
manual:
use_for_https: true # Also use this proxy for HTTPS
https_proxy:
description: HTTPS Proxy
hidden:
variable: _.use_for_https
address:
description: HTTPS address
type: domainname
params:
allow_ip: true
port:
description: HTTPS Port
type: port
default: 8080
...

View file

@ -1 +1 @@
A calculated default value
A disabled family

View file

@ -1 +1 @@
Calculated default value for a variable
Define access to variable or family

View file

@ -1,9 +1 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
https_proxy:
address: https.proxy.net

View file

@ -0,0 +1,7 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false

View file

@ -0,0 +1,21 @@
%YAML 1.2
---
version: 1.1
manual:
description: Manual proxy configuration
disabled: true
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
...

1
examples/041/README.md Normal file
View file

@ -0,0 +1 @@
A conditional disabled family

View file

@ -0,0 +1,7 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false

View file

@ -0,0 +1,23 @@
%YAML 1.2
---
version: 1.1
manual:
description: Manual proxy configuration
disabled:
variable: _.proxy_mode
when_not: Manual proxy configuration
http_proxy: # HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
...

1
examples/042/README.md Normal file
View file

@ -0,0 +1 @@
A hidden family

View file

@ -6,7 +6,9 @@ manual:
use_for_https: true # Also use this proxy for HTTPS
https_proxy: # HTTPS Proxy
https_proxy:
description: HTTPS Proxy
hidden: true
address:
description: HTTPS address

1
examples/043/README.md Normal file
View file

@ -0,0 +1 @@
A conditional hidden family

View file

@ -0,0 +1,9 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: false
https_proxy:
address: https.proxy.net

View file

@ -0,0 +1,7 @@
---
proxy_mode: Manual proxy configuration
manual:
http_proxy:
address: http.proxy.net
port: 3128
use_for_https: true

View file

@ -13,11 +13,12 @@ manual:
address:
description: HTTPS address
default:
variable: __.http_proxy.address
type: domainname
params:
allow_ip: true
port:
description: HTTPS Port
default:
variable: __.http_proxy.port
type: port
default: 8080
...

View file

@ -1 +1 @@
Family: a dynamic family
A calculated default value

View file

@ -1 +1 @@
Dynamic family
Calculated default value for a variable

View file

@ -1 +0,0 @@
https://pedago.gwenaelremond.fr/bribes/rougail/tutorial/dynfam.html

View file

@ -1 +0,0 @@
../018/config

Some files were not shown because too many files have changed in this diff Show more