Fix docstrings

This commit is contained in:
s3lph 2019-11-25 03:14:14 +01:00
parent c4be5f499a
commit 8d71a0b457
5 changed files with 23 additions and 22 deletions

0
README.md Normal file
View file

View file

@ -7,10 +7,10 @@ __CONFIG = {}
def load(filename: str) -> None:
'''
"""
Load a JSON-formatted configuration file.
@param filename The config file to load.
'''
:type filename: The config file to load.
"""
global __CONFIG
# Open and parse the JSON config file
with open(filename, 'r') as conf:
@ -18,8 +18,8 @@ def load(filename: str) -> None:
def get() -> dict:
'''
"""
Return the current configuration.
'''
"""
global __CONFIG
return __CONFIG

View file

@ -3,10 +3,10 @@ from spaceapi_server.template import env_init
def template_function(fn):
'''
"""
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
env = env_init()
# Add the function to the environment's globals
@ -15,10 +15,10 @@ def template_function(fn):
def template_filter(fn):
'''
"""
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
env = env_init()
# Add the function to the environment's filters
@ -27,10 +27,10 @@ def template_filter(fn):
def template_test(fn):
'''
"""
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
env = env_init()
# Add the function to the environment's tests

View file

@ -14,10 +14,11 @@ __TEMPLATE = None
def render_traverse(obj):
'''
"""
Walk through a complex, JSON-serializable data structure, and pass
string objects through the Jinja2 templating engine.
'''
:type obj: The object to traverse.
"""
if isinstance(obj, list):
# list -> recurse into each item
for i in range(len(obj)):

View file

@ -8,10 +8,10 @@ _ENV = None
def env_init(force: bool = False):
'''
"""
Initialize the Jinja2 environment.
@param force If true, force reload the environment.
'''
:type force: If true, force reload the environment.
"""
global _ENV
if _ENV is None or force:
# 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):
'''
"""
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
env = env_init()
# Create a Jinja2 template from the input string