-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: ajout d'une doc static pour le schéma #37
base: main
Are you sure you want to change the base?
Conversation
code_insee: Optional[common.CodeCommune] = None | ||
adresse: Optional[str] = None | ||
code_insee: Optional[common.CodeCommune] = Field( | ||
description="[Deprecated]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description="[Deprecated]", |
model_name = model.__name__.lower() | ||
with (docs_dir / f"{model_name}.md").open("w") as file: | ||
file.write( | ||
jinja2.Template(open(docs_dir / "model.md.j2").read()).render( |
Check warning
Code scanning / CodeQL
Jinja2 templating with autoescape=False Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 18 hours ago
To fix the problem, we need to ensure that Jinja2's autoescape
feature is enabled when creating the template environment. This can be done by using the select_autoescape
function, which will automatically enable escaping for specific file extensions such as HTML and XML.
The best way to fix this without changing existing functionality is to create a Jinja2 Environment
with autoescape
set to select_autoescape(['html', 'xml'])
and then use this environment to get the template. This ensures that any HTML or XML content is properly escaped, preventing XSS attacks.
-
Copy modified lines R86-R90 -
Copy modified line R93
@@ -85,5 +85,10 @@ | ||
model_name = model.__name__.lower() | ||
env = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(docs_dir), | ||
autoescape=jinja2.select_autoescape(['html', 'xml']) | ||
) | ||
template = env.get_template("model.md.j2") | ||
with (docs_dir / f"{model_name}.md").open("w") as file: | ||
file.write( | ||
jinja2.Template(open(docs_dir / "model.md.j2").read()).render( | ||
template.render( | ||
schema=model.model_json_schema(), |
ref_dir.mkdir(exist_ok=True) | ||
with (ref_dir / f"{referential_name}.md").open("w") as file: | ||
file.write( | ||
jinja2.Template(open(docs_dir / "referentiel.md.j2").read()).render( |
Check warning
Code scanning / CodeQL
Jinja2 templating with autoescape=False Medium
d2adc35
to
7cbef1f
Compare
docs/referentiel.md.j2
Outdated
{% for referential_item in referential %} | ||
### `{{ referential_item.value }}` | ||
|
||
Label: {{ referential_item.label }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label: {{ referential_item.label }} | |
Label : {{ referential_item.label }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
la petite règle en français : espace avant et après les deux points :
https://www.blogdumoderateur.com/regles-ponctuation-typographie/
docs/referentiel.md.j2
Outdated
Label: {{ referential_item.label }} | ||
|
||
{% if referential_item.description %} | ||
Description: {{ referential_item.description }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: {{ referential_item.description }} | |
Description : {{ referential_item.description }} |
ff00162
to
997b04e
Compare
Pour tester:
Liste des features:
Les champs interessant a regarder:
Niveau du fichier jinja vous pouvez faire la review, si vous avez des tips je suis preneur (djlint m'a bien servi par exemple)
Je vais retoucher la partie en python sur main et l'ecrire en objet pour simplifier mais il va me faloir une demi journee de plus.