Giter VIP home page Giter VIP logo

flask-autodoc's People

Contributors

ballisticbuddha avatar jwg4 avatar lukeyeager avatar wshayes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-autodoc's Issues

@auto.doc decorator problem

Using the following:
Python 2.7.6
Flask==0.10.1
Flask-Bootstrap==3.1.1.2
Flask-DebugToolbar==0.9.0
Flask-Login==0.2.11
Flask-Mail==0.9.0
Flask-Principal==0.4.0
Flask-Security==1.7.3
Flask-WTF==0.10.0
Jinja2==2.7.3
MarkupSafe==0.23
WTForms==2.0.1
Werkzeug==0.9.6
blinker==1.3
itsdangerous==0.24
mongoengine==0.8.7
passlib==1.6.2
pymongo==2.7.2
wsgiref==0.1.2

Getting this error when I add the @auto.doc to my endpoints:

Traceback (most recent call last):
File "./agencies.py", line 246, in
@auto.doc
File "/Users/william/code/agencyeditor/agencyweb/lib/python2.7/site-packages/flask/app.py", line 1013, in decorator
self.add_url_rule(rule, endpoint, f, *_options)
File "/Users/william/code/agencyeditor/agencyweb/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
return f(self, *args, *_kwargs)
File "/Users/william/code/agencyeditor/agencyweb/lib/python2.7/site-packages/flask/app.py", line 984, in add_url_rule
'existing endpoint function: %s' % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: decorator

Any idea what the problem is? Thanks!

ExtDeprecationWarning: Importing flask.ext.autodoc is deprecated

I have a message with flask 1.10

/usr/local/lib/python3.4/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.autodoc is deprecated, use flask_autodoc instead.

I test replace in init.py

from flask.ext.autodoc.autodoc import Autodoc

by

from flask_autodoc.autodoc import Autodoc

And is ok. Can you modify your code ?
Thank you for module

Question about Form Data

Hello

In the 2nd example picture (/doc/private) you have a Form Data section under the Description for the route /post.
I checked the examples, but i can get it to work for me.
I have a template with this

<div class="desc">
                Description : {{doc.docstring}}
</div>

that display the content of what i put between """ ... """ in my code, and in your example you do this :

 """Create a new post.
    Form Data: title, content, authorid.
    """

'Create a new post ' i corectly going in the description and 'Form Data' i going to form data, however when i do the same thing, both go into the description.

How did you manage to add the FormData rule ?

Thanks

error starting custom example

I tried to work out and fix the following issue, but couldn't :(

python blog.py
Traceback (most recent call last):
File "blog.py", line 61, in
form_data=['title', 'content', 'authorid'])
TypeError: doc() got an unexpected keyword argument 'form_data'

Cannot import for python 3

I installed Flask-Autodoc (0.1.1) like all my packages using : pip install flask-autodoc and python3

When I tried to import Flask-Autodoc , I get this following error :

   In [4]: from flask.ext.autodoc import Autodoc
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-b490edb37e00> in <module>()
----> 1 from flask.ext.autodoc import Autodoc

/Users/sacha/dev/wingo-server/venv/lib/python3.4/site-packages/flask/exthook.py in load_module(self, fullname)
     79                 # is the one from __import__ above which we don't care about
     80                 if self.is_important_traceback(realname, tb):
---> 81                     reraise(exc_type, exc_value, tb.tb_next)
     82                 continue
     83             module = sys.modules[fullname] = sys.modules[realname]

/Users/sacha/dev/wingo-server/venv/lib/python3.4/site-packages/flask/_compat.py in reraise(tp, value, tb)
     30     def reraise(tp, value, tb=None):
     31         if value.__traceback__ is not tb:
---> 32             raise value.with_traceback(tb)
     33         raise value
     34 

/Users/sacha/dev/wingo-server/venv/lib/python3.4/site-packages/flask_autodoc/__init__.py in <module>()
      1 __author__ = 'arnaud'
----> 2 from autodoc import Autodoc

ImportError: No module named 'autodoc'

does this extension support flask-restful

I want to check that if this extensions support flask-restful, here is my test code:

from flask_autodoc.autodoc import Autodoc
from flask_restful import Resource,Api
class Post(Resource):

    @auto.doc()
    def get(self):
        return 'post'
class Doc(Resource):
    def get(self):
        return auto.html()

api = Api(app)
api.add_resource(Post,'/post')
api.add_resource(Doc,'/doc')

however, the results shows that it does not support the flask-restful api:
image

thanks

zhangzheng

Unittests cannot be run more than once without cleaning .pyc files

This is mainly an issue for local development by running the unittests locally.
Found with Python 2.7.6

To reproduce:

  • from the root of the project directory, run python -m unittest discover
  • from the same place, without altering the unittest file test_autodoc.py file, run python -m unittest discover again

This results in the following error:

======================================================================
FAIL: testGet (tests.test_autodoc.TestAutodoc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/alex/git/flask-autodoc/tests/test_autodoc.py", line 33, in testGet
    self.assertIn(__file__, d['location']['filename'])
AssertionError: '/home/alex/git/flask-autodoc/tests/test_autodoc.pyc' not found in '/home/alex/git/flask-autodoc/tests/test_autodoc.py'

======================================================================
FAIL: testPost (tests.test_autodoc.TestAutodoc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/alex/git/flask-autodoc/tests/test_autodoc.py", line 53, in testPost
    self.assertIn(__file__, d['location']['filename'])
AssertionError: '/home/alex/git/flask-autodoc/tests/test_autodoc.pyc' not found in '/home/alex/git/flask-autodoc/tests/test_autodoc.py'

This is due to the tests that verify the location property being run from the compiled .pyc bytecode, therefore making the source of the actual file running the test the .pyc file, which appears as the __file__ attribute in this scenario.

I can see three possible solutions to this:

  • Ignore the last character from the value being asserted if it is a 'c' character.
  • Swap the values being asserted, making the line become self.assertIn(d['location']['filename'], __file__). This isn't as clear when read, but basically because the expected value '/path/to/project/test/test_autodoc.py' is contained in the string '/path/to/project/test/test_autodoc.pyc', it should pass the assertion.
  • Run the unittests from a Makefile or similar that does a clean of the environment by removing excess artifacts such as .pyc files.

custom comment at each method

I would like to be able to add a custom comment on each API function descriptions that appears in the report. Is it already possible? Would you develop that?

Thanks

gae keyerror main

Looks like gae limitation

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/alexey/projects/coolproject/main.py", line 35, in <module>
    @auto.doc()
  File "/Users/alexey/projects/coolproject/lib/flask_autodoc/autodoc.py", line 104, in decorator
    caller_frame = inspect.stack()[1]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1055, in stack
    return getouterframes(sys._getframe(1), context)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1033, in getouterframes
    framelist.append((frame,) + getframeinfo(frame, context))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 1008, in getframeinfo
    lines, lnum = findsource(frame)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 532, in findsource
    module = getmodule(object, file)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 504, in getmodule
    main = sys.modules['__main__']
KeyError: '__main__'

jinja2.exceptions.TemplateAssertionError: no filter named 'nl2br'

Seems like there is a missing filter in autodoc_default.html , which results in error like:
raise TemplateAssertionError(msg, lineno, self.name, self.filename) jinja2.exceptions.TemplateAssertionError: no filter named 'nl2br'

Workaround for this is to add into Flask app:


    @app.template_filter()
    @evalcontextfilter
    def nl2br(eval_ctx, value):
        result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n') \
                              for p in _paragraph_re.split(escape(value)))
        if eval_ctx.autoescape:
            result = Markup(result)
        return result

Python 3.6
pip freeze:
Flask==0.12.2
Jinja2==2.9.6
Flask-Autodoc==0.1.2

doc generation for route is sensible to decorator orders

Hi,
with Python 3.5.3, Flask 0.12.2 and flask-autodoc 0.1.2.
It seems to me that doc won't generate for a route if the @auto.doc() decorator isn't immediately after the @app.route one.
In the case of multiple decorators, this behavior is a little bit disturbing.
This is not really a bug, but I think it should be mentioned in the documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.