-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c65d293
commit cf47452
Showing
1 changed file
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
import os | ||
|
||
|
||
def define_env(env): | ||
"""Définir les variables, macros et filtres.""" | ||
"""Define variables, macros, and filters. | ||
Args: | ||
env: The environment object used for defining macros and variables. | ||
Returns: | ||
None | ||
""" | ||
@env.macro | ||
def include_file(filename): | ||
"""Inclure le contenu d'un fichier.""" | ||
def include_file(filename: str) ->str: | ||
"""Include the contents of a file. | ||
Args: | ||
filename (str): The name of the file to include. | ||
Returns: | ||
str: The content of the file with specific replacements made, | ||
or an error message if the file is not found. | ||
Raises: | ||
FileNotFoundError: If the specified file cannot be found. | ||
""" | ||
try: | ||
with open(filename, "r", encoding="utf-8") as file: | ||
content = file.read().replace("website/docs/", "") | ||
content = content.replace("[AUTHORS](AUTHORS)", "[AUTHORS](./authors.md)") | ||
return content | ||
except FileNotFoundError: | ||
return f"File not found: {filename}" | ||
return f"File not found: {filename}" |