Skip to content

Commit

Permalink
Merge pull request Cornices#284 from MikaYuoadas/master
Browse files Browse the repository at this point in the history
sphinx extension: display default values
  • Loading branch information
almet committed Apr 4, 2015
2 parents 461d609 + 9f8fff6 commit aa44663
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cornice/ext/sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Sphinx extension that is able to convert a service into a documentation.
"""
import sys
import json
from importlib import import_module

from cornice.util import to_list, is_string, PY3
Expand Down Expand Up @@ -139,7 +140,13 @@ def _render_service(self, service):
if not attr.required or attr.description:
temp += nodes.inline(text=' - ')
if not attr.required:
temp += nodes.inline(text='(optional) ')
if attr.missing is not None:
default = json.dumps(attr.missing)
temp += nodes.inline(
text='(default: %s) ' % default)
else:
temp += nodes.inline(
text='(optional) ')
if attr.description:
temp += nodes.inline(text=attr.description)

Expand Down

0 comments on commit aa44663

Please sign in to comment.