Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated docs are incorrectly formatted with Flask 0.11.1 #26

Open
rsmith-ip opened this issue Jun 13, 2016 · 7 comments
Open

Generated docs are incorrectly formatted with Flask 0.11.1 #26

rsmith-ip opened this issue Jun 13, 2016 · 7 comments

Comments

@rsmith-ip
Copy link

rsmith-ip commented Jun 13, 2016

The formatting works fine with Flask 0.10.1 but with 0.11.1 the embedded HTML tags are displayed instead of being processed as HTML.

@rsmith-ip rsmith-ip changed the title Generated docs are incorrectly formatted with Flask 11.1 Generated docs are incorrectly formatted with Flask 0.11.1 Jun 13, 2016
@T0SH1R0
Copy link

T0SH1R0 commented Sep 23, 2016

Actually it would be wonderful if autodoc could parse markdown from the docstring. It's far more easy and useful then giant Spynx or Doxygen. And parsing markdown is EVERYTHING we need for documentation.

@alitheg
Copy link

alitheg commented Oct 14, 2016

This happens also in 0.11.0

@stanislavvv
Copy link

markdown may rendered without any patches in flask-autodoc:

  1. create filter for markdown and add it to jinja
[...]
import markdown
from flask import Markup

def md2html(text):
    import textwrap
    res = Markup(markdown.markdown(
        textwrap.dedent(text),
        [
            'markdown.extensions.codehilite',
            'markdown.extensions.nl2br',
            'markdown.extensions.extra',
            'markdown.extensions.admonition'
        ], extension_configs={'markdown.extensions.codehilite': {
            'noclasses': True,
            'pygments_style': 'colorful'
        }}))
    return res

def create_app():
    app = Flask(__name__, static_url_path='/doc')
[...]
    app.jinja_env.filters['markdown'] = md2html
[...]
  1. use custom templates:
<p>{% autoescape false %}{{doc.docstring|markdown}}{% endautoescape %}</p>

I'm take some css strings from sphinx, but you welcome to create your own.

@jkwill87
Copy link

going off of @stanislavvv 's response, with respect to the original issue if you just want flask-autodoc to format html using tags embedded in docstrings (less all the markdown business) you can use {% autoescape false %}{{doc.docstring|urlize|nl2br}}{% endautoescape %} in the template file

@mjgorman
Copy link

I'm having the same issue, I'm not using a custom template. Just return auto.html() per the basic examples.

@macsz
Copy link

macsz commented Jul 19, 2017

Confirmed with Flask 0.12.2 as well.
Without using templates the simplest solution is to roll back Flask to 0.10.

@popokatapepel
Copy link

as a workaround you can copy the default template from
Flask_Autodoc-0.1.2-py3.4.egg\flask_autodoc\templates\autodoc_default.html
to your aplication
\templates

afterwards change the line
<p class="docstring">{{doc.docstring|urlize|nl2br}}</p> to
<p class="docstring">{{doc.docstring|urlize|nl2br|safe}}</p>

when you use auto.html() define the project template to use it
return auto.html(template='autodoc_default.html')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants