Passed
Branch master (3ecb90)
by jvo
01:31
created

__render_md()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
cc 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
1 1
import os
2 1
import glob
3 1
import markdown
0 ignored issues
show
Configuration introduced by
The import markdown could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
4
5 1
try:  # python3 ftw !
6 1
    from StringIO import StringIO
7
except ImportError:
8
    from io import StringIO
9
10 1
from flask import Blueprint, render_template, redirect
1 ignored issue
show
Configuration introduced by
The import flask could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
11
12 1
docs = Blueprint('docs', __name__)
0 ignored issues
show
Coding Style Naming introduced by
The name docs does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
13
14
15 1
def __render_md(md_file):
16
    """
17
    :param str md_file: Path to a markdown file
18
    :return str: html rendering of the `md_file` markdown file
19
    """
20 1
    ret = StringIO()
21 1
    markdown.markdownFromFile(input=md_file, output=ret, encoding='utf-8')
22 1
    return ret.getvalue()
23
24
25 1
@docs.route("/")
26
def index():
27 1
    return render_template("docs/index.html", data=__render_md("docs/docs.md"))
28
29
30 1
@docs.route("/<path:doc_file>")
31
def display(doc_file):
32 1
    if doc_file == 'README.md':
33 1
        doc_path = 'README.md'
34
    else:
35 1
        doc_path = os.path.join("docs", doc_file)
36 1
        if doc_path not in glob.glob("docs/*.md"):
37 1
            return redirect('/docs')
38
    return render_template("docs/index.html", data=__render_md(doc_path), title='<a href="/docs">Spike - Docs</a>')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (115/90).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
39