Fix docstrings
This commit is contained in:
parent
c4be5f499a
commit
8d71a0b457
5 changed files with 23 additions and 22 deletions
0
README.md
Normal file
0
README.md
Normal file
|
@ -7,10 +7,10 @@ __CONFIG = {}
|
||||||
|
|
||||||
|
|
||||||
def load(filename: str) -> None:
|
def load(filename: str) -> None:
|
||||||
'''
|
"""
|
||||||
Load a JSON-formatted configuration file.
|
Load a JSON-formatted configuration file.
|
||||||
@param filename The config file to load.
|
:type filename: The config file to load.
|
||||||
'''
|
"""
|
||||||
global __CONFIG
|
global __CONFIG
|
||||||
# Open and parse the JSON config file
|
# Open and parse the JSON config file
|
||||||
with open(filename, 'r') as conf:
|
with open(filename, 'r') as conf:
|
||||||
|
@ -18,8 +18,8 @@ def load(filename: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
def get() -> dict:
|
def get() -> dict:
|
||||||
'''
|
"""
|
||||||
Return the current configuration.
|
Return the current configuration.
|
||||||
'''
|
"""
|
||||||
global __CONFIG
|
global __CONFIG
|
||||||
return __CONFIG
|
return __CONFIG
|
||||||
|
|
|
@ -3,10 +3,10 @@ from spaceapi_server.template import env_init
|
||||||
|
|
||||||
|
|
||||||
def template_function(fn):
|
def template_function(fn):
|
||||||
'''
|
"""
|
||||||
Register the decorated function as a callable template function.
|
Register the decorated function as a callable template function.
|
||||||
@param fn The function to register.
|
:type fn: The function to register.
|
||||||
'''
|
"""
|
||||||
# Make sure the Jinja2 environment is initialized
|
# Make sure the Jinja2 environment is initialized
|
||||||
env = env_init()
|
env = env_init()
|
||||||
# Add the function to the environment's globals
|
# Add the function to the environment's globals
|
||||||
|
@ -15,10 +15,10 @@ def template_function(fn):
|
||||||
|
|
||||||
|
|
||||||
def template_filter(fn):
|
def template_filter(fn):
|
||||||
'''
|
"""
|
||||||
Register the decorated function as a template filter.
|
Register the decorated function as a template filter.
|
||||||
@param fn The function to register.
|
:type fn: The function to register.
|
||||||
'''
|
"""
|
||||||
# Make sure the Jinja2 environment is initialized
|
# Make sure the Jinja2 environment is initialized
|
||||||
env = env_init()
|
env = env_init()
|
||||||
# Add the function to the environment's filters
|
# Add the function to the environment's filters
|
||||||
|
@ -27,10 +27,10 @@ def template_filter(fn):
|
||||||
|
|
||||||
|
|
||||||
def template_test(fn):
|
def template_test(fn):
|
||||||
'''
|
"""
|
||||||
Register the decorated function as a template test.
|
Register the decorated function as a template test.
|
||||||
@param fn The function to register.
|
:type fn: The function to register.
|
||||||
'''
|
"""
|
||||||
# Make sure the Jinja2 environment is initialized
|
# Make sure the Jinja2 environment is initialized
|
||||||
env = env_init()
|
env = env_init()
|
||||||
# Add the function to the environment's tests
|
# Add the function to the environment's tests
|
||||||
|
|
|
@ -14,10 +14,11 @@ __TEMPLATE = None
|
||||||
|
|
||||||
|
|
||||||
def render_traverse(obj):
|
def render_traverse(obj):
|
||||||
'''
|
"""
|
||||||
Walk through a complex, JSON-serializable data structure, and pass
|
Walk through a complex, JSON-serializable data structure, and pass
|
||||||
string objects through the Jinja2 templating engine.
|
string objects through the Jinja2 templating engine.
|
||||||
'''
|
:type obj: The object to traverse.
|
||||||
|
"""
|
||||||
if isinstance(obj, list):
|
if isinstance(obj, list):
|
||||||
# list -> recurse into each item
|
# list -> recurse into each item
|
||||||
for i in range(len(obj)):
|
for i in range(len(obj)):
|
||||||
|
|
|
@ -8,10 +8,10 @@ _ENV = None
|
||||||
|
|
||||||
|
|
||||||
def env_init(force: bool = False):
|
def env_init(force: bool = False):
|
||||||
'''
|
"""
|
||||||
Initialize the Jinja2 environment.
|
Initialize the Jinja2 environment.
|
||||||
@param force If true, force reload the environment.
|
:type force: If true, force reload the environment.
|
||||||
'''
|
"""
|
||||||
global _ENV
|
global _ENV
|
||||||
if _ENV is None or force:
|
if _ENV is None or force:
|
||||||
# Use json.dumps as finalizer in order to preserve complex data structures
|
# Use json.dumps as finalizer in order to preserve complex data structures
|
||||||
|
@ -20,10 +20,10 @@ def env_init(force: bool = False):
|
||||||
|
|
||||||
|
|
||||||
def render(template: str):
|
def render(template: str):
|
||||||
'''
|
"""
|
||||||
Render the given string as a Jinja2 template.
|
Render the given string as a Jinja2 template.
|
||||||
@param template The template string to render
|
:type template: The template string to render.
|
||||||
'''
|
"""
|
||||||
# Make sure the Jinaj2 environment is initialized
|
# Make sure the Jinaj2 environment is initialized
|
||||||
env = env_init()
|
env = env_init()
|
||||||
# Create a Jinja2 template from the input string
|
# Create a Jinja2 template from the input string
|
||||||
|
|
Loading…
Reference in a new issue