Skip to content

Commit

Permalink
fix: fix bug from python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kwkwc committed Oct 29, 2020
1 parent cb73de5 commit d3c0d0d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# python2.7 venv
venv2.7/
2 changes: 1 addition & 1 deletion examples/sample/sample_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Api Document needs to be displayed
app.config['API_DOC_MEMBER'] = ['api', 'platform']

ApiDoc(app, title='Sample App', version='0.1.9')
ApiDoc(app, title='Sample App', version='0.2.0')

api = Blueprint('api', __name__)
platform = Blueprint('platform', __name__)
Expand Down
2 changes: 1 addition & 1 deletion examples/sample/sample_app_restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
app.config['RESTFUL_API_DOC_EXCLUDE'] = []

restful_api = Api(app)
ApiDoc(app, title='Sample App Restful', version='0.1.9')
ApiDoc(app, title='Sample App Restful', version='0.2.0')


class TodoList(Resource):
Expand Down
2 changes: 1 addition & 1 deletion examples/sample/sample_app_restful_methodview .py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# RESTful Api documents to be excluded
app.config['RESTFUL_API_DOC_EXCLUDE'] = []

ApiDoc(app, title='Sample App Restful Methodview', version='0.1.9')
ApiDoc(app, title='Sample App Restful Methodview', version='0.2.0')


class TodoList(MethodView):
Expand Down
24 changes: 12 additions & 12 deletions flask_docs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Program:
Flask-Docs
Version:
0.1.9
0.2.0
History:
Created on 2018/05/20
Last modified on 2020/10/29
Last modified on 2020/10/30
Author:
kwkw
'''
Expand Down Expand Up @@ -136,12 +136,12 @@ def data():

# Api
for rule in app.url_map.iter_rules():
r = str(rule).split('/')[1]
if r not in current_app.config['API_DOC_MEMBER']:
f = str(rule).split('/')[1]
if f not in current_app.config['API_DOC_MEMBER']:
continue

if r.capitalize() not in dataDict:
dataDict[r.capitalize()] = {'children': []}
if f.capitalize() not in dataDict:
dataDict[f.capitalize()] = {'children': []}

api = {
'name': '',
Expand All @@ -150,7 +150,7 @@ def data():
'method': '',
'doc': '',
'doc_md': '',
'router': r.capitalize(),
'router': f.capitalize(),
'api_type': 'api'
}

Expand All @@ -163,7 +163,7 @@ def data():
[r for r in rule.methods if r in ApiDoc.METHODS_LIST])

result = filter(
lambda x: x['name'] == name, dataDict[r.capitalize()]['children'])
lambda x: x['name'] == name, dataDict[f.capitalize()]['children'])
result_list = list(result)
if len(result_list) > 0:
result_list[0]['url'] = result_list[0]['url'] + ' ' + url
Expand All @@ -187,12 +187,12 @@ def data():
except Exception as e:
pass
else:
dataDict[r.capitalize()]['children'].append(api)
dataDict[f.capitalize()]['children'].append(api)

if dataDict[r.capitalize()]['children'] == []:
dataDict.pop(r.capitalize())
if dataDict[f.capitalize()]['children'] == []:
dataDict.pop(f.capitalize())
else:
dataDict[r.capitalize()]['children'].sort(
dataDict[f.capitalize()]['children'].sort(
key=lambda x: x['name'])

return jsonify({'data': dataDict, 'title': title, 'version': version, 'noDocText': ApiDoc.NO_DOC})
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(fname):

setup(
name='Flask-Docs',
version='0.1.9',
version='0.2.0',
url='https://github.com/kwkwc/flask-docs',
license='MIT',
author='kwkw',
Expand Down

0 comments on commit d3c0d0d

Please sign in to comment.