Skip to content

Commit f3368d0

Browse files
committed
Merge branch '1.6'
2 parents 6a81ad0 + ca254cc commit f3368d0

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ script:
1010
| grep '\[changelog skip\]' > /dev/null; then
1111
echo "Skip changelog checker..."
1212
elif [[ "$TRAVIS_TAG" != "" ]]; then
13-
! grep -i "to be released" CHANGES.rst
13+
! grep -i "to be released" doc/changelog.rst
1414
else
1515
[[ "$TRAVIS_COMMIT_RANGE" = "" ]] || \
1616
[[ "$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep doc/changelog\.rst)" != "" ]]

doc/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Version 1.7.0
88

99
To be released.
1010

11+
- Implemented ``:autoquickref:`` option that use available informations to
12+
build a ``quickref``. [:pull:`9` by Alexandre Bonnetain]
1113
- Improved :mod:`sphinxcontrib.autohttp.tornado` compatibility with Tornado
1214
4.5 and newer. `Tornado 4.5 <http://www.tornadoweb.org/en/stable/releases/v4.5.0.html>`
1315
introduced the ``Rule`` class and made ``URLSpec`` a subclass of it, so certain

sphinxcontrib/autohttp/flask_base.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,20 @@ def get_routes(app, endpoint=None, order=None):
6666
yield method, paths, endpoint
6767

6868

69+
def get_blueprint(app, view_func):
70+
for name, func in app.view_functions.items():
71+
if view_func is func:
72+
return name.split('.')[0]
73+
74+
6975
def cleanup_methods(methods):
7076
autoadded_methods = frozenset(['OPTIONS', 'HEAD'])
7177
if methods <= autoadded_methods:
7278
return methods
7379
return methods.difference(autoadded_methods)
7480

7581

76-
def quickref_directive(method, path, content):
82+
def quickref_directive(method, path, content, blueprint=None, auto=False):
7783
rcomp = re.compile("^\s*.. :quickref:\s*(?P<quick>.*)$")
7884
method = method.lower().strip()
7985
if isinstance(content, six.string_types):
@@ -94,6 +100,12 @@ def quickref_directive(method, path, content):
94100
description = quickref
95101
break
96102

103+
if auto:
104+
if not description and content:
105+
description = content[0]
106+
if not name and blueprint:
107+
name = blueprint
108+
97109
row = {}
98110
row['name'] = name
99111
row['operation'] = ' - `%s %s <#%s-%s>`_' % (
@@ -115,7 +127,8 @@ class AutoflaskBase(Directive):
115127
'undoc-blueprints': directives.unchanged,
116128
'undoc-modules': directives.unchanged,
117129
'undoc-static': directives.unchanged,
118-
'include-empty-docstring': directives.unchanged}
130+
'include-empty-docstring': directives.unchanged,
131+
'autoquickref': directives.flag}
119132

120133
@property
121134
def endpoints(self):
@@ -248,8 +261,11 @@ def make_rst(self, qref=False):
248261
for method, paths, view_func, view_doc in routes:
249262
docstring = prepare_docstring(view_doc)
250263
if qref:
264+
auto = self.options.get("autoquickref", False) is None
265+
blueprint = get_blueprint(app, view_func)
251266
for path in paths:
252-
row = quickref_directive(method, path, docstring)
267+
row = quickref_directive(method, path, docstring,
268+
blueprint, auto=auto)
253269
yield row
254270
else:
255271
for line in http_directive(method, paths, docstring):

0 commit comments

Comments
 (0)