1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

fix docstrings

This commit is contained in:
checktheroads
2019-12-31 01:16:55 -07:00
parent 407c575254
commit 56d136a72b
3 changed files with 30 additions and 21 deletions

View File

@ -1,6 +1,4 @@
"""
Renders Jinja2 & Sass templates for use by the front end application
"""
"""Renders Jinja2 & Sass templates for use by the front end application."""
# Project Imports
# flake8: noqa: F401

View File

@ -129,11 +129,19 @@ ets/traceroute_nanog.pdf" target="_blank">click here</a>.
def generate_markdown(section, file_name=None):
"""
Renders markdown as HTML. If file_name exists in appropriate
directory, it will be imported and used. If not, the default values
will be used. Also renders the Front Matter values within each
template.
"""Render markdown as HTML.
Arguments:
section {str} -- Section name
Keyword Arguments:
file_name {str} -- Markdown file name (default: {None})
Raises:
HyperglassError: Raised if YAML front matter is unreadable
Returns:
{dict} -- Frontmatter dictionary
"""
if section == "help":
file = working_directory.joinpath("templates/info/help.md")
@ -188,13 +196,22 @@ def generate_markdown(section, file_name=None):
def render_html(template_name, **kwargs):
"""Render Jinja2 HTML templates."""
"""Render Jinja2 HTML templates.
Arguments:
template_name {str} -- Jinja2 template name
Raises:
HyperglassError: Raised if template is not found
Returns:
{str} -- Rendered template
"""
details_name_list = ["footer", "bgp_aspath", "bgp_community"]
details_dict = {}
for details_name in details_name_list:
details_data = generate_markdown("details", details_name)
details_dict.update({details_name: details_data})
info_list = ["bgp_route", "bgp_aspath", "bgp_community", "ping", "traceroute"]
rendered_help = generate_markdown("help")
log.debug(rendered_help)
try:

View File

@ -26,10 +26,7 @@ env = jinja2.Environment(
def render_frontend_config():
"""
Renders user config to JSON file so front end config can be used by
Javascript
"""
"""Render user config to JSON for use by frontend."""
rendered_frontend_file = hyperglass_root.joinpath("static/src/js/frontend.json")
try:
with rendered_frontend_file.open(mode="w") as frontend_file:
@ -48,7 +45,7 @@ def render_frontend_config():
def get_fonts():
"""Downloads google fonts"""
"""Download Google fonts."""
font_dir = hyperglass_root.joinpath("static/src/sass/fonts")
font_bin = str(
hyperglass_root.joinpath("static/src/node_modules/get-google-fonts/cli.js")
@ -77,7 +74,7 @@ def get_fonts():
def render_theme():
"""Renders Jinja2 template to Sass file"""
"""Render Jinja2 template to Sass file."""
rendered_theme_file = hyperglass_root.joinpath("static/src/sass/theme.sass")
try:
template = env.get_template("templates/theme.sass.j2")
@ -92,7 +89,7 @@ def render_theme():
def build_assets():
"""Builds, bundles, and minifies Sass/CSS/JS web assets"""
"""Build, bundle, and minify Sass/CSS/JS web assets."""
proc = subprocess.Popen(
["yarn", "--silent", "--emoji", "false", "--json", "--no-progress", "build"],
cwd=hyperglass_root.joinpath("static/src"),
@ -116,10 +113,7 @@ def build_assets():
def render_assets():
"""
Controller function for rendering sass theme elements and building
web assets
"""
"""Run web asset rendering functions."""
try:
log.debug("Rendering front end config...")
render_frontend_config()