本文整理汇总了Python中sphinx.util.force_decode方法的典型用法代码示例。如果您正苦于以下问题:Python util.force_decode方法的具体用法?Python util.force_decode怎么用?Python util.force_decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.util
的用法示例。
在下文中一共展示了util.force_decode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self):
app = import_object(self.arguments[0])
for method, path, target in get_routes(app):
endpoint = target.name or target.callback.__name__
if self.endpoints and endpoint not in self.endpoints:
continue
if endpoint in self.undoc_endpoints:
continue
view = target.callback
docstring = view.__doc__ or ''
if not isinstance(docstring, six.text_type):
analyzer = ModuleAnalyzer.for_module(view.__module__)
docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
docstring = prepare_docstring(docstring)
for line in http_directive(method, path, docstring):
yield line
示例2: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self):
app = import_object(self.arguments[0])
for method, path, handler in get_routes(app):
class_name = handler.__name__
method_name = getattr(handler, method).__name__
endpoint = '.'.join((class_name, method_name))
if self.endpoints and endpoint not in self.endpoints:
continue
if endpoint in self.undoc_endpoints:
continue
docstring = getattr(handler, method).__doc__ or ''
#if not isinstance(docstring, unicode):
# analyzer = ModuleAnalyzer.for_module(view.__module__)
# docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
docstring = prepare_docstring(docstring)
for line in http_directive(method, normalize_path(path), docstring):
yield line
示例3: get_doc
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def get_doc(self, encoding=None):
content = self.env.config.autoclass_content
docstrings = []
docstring = self.get_attr(self.object, '__doc__', None)
if docstring:
docstrings.append(docstring)
# for classes, what the "docstring" is can be controlled via a
# config value; the default is only the class docstring
if content in ('both', 'init'):
initdocstring = self.get_attr(
self.get_attr(self.object, '__init__', None), '__doc__')
# for new-style classes, no __init__ means default __init__
if initdocstring == object.__init__.__doc__:
initdocstring = None
if initdocstring:
if content == 'init':
docstrings = [initdocstring]
else:
docstrings.append(initdocstring)
return [prepare_docstring(force_decode(docstring, encoding))
for docstring in docstrings]
示例4: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self):
app = import_object(self.arguments[0])
for method, path, endpoint in get_routes(app):
try:
blueprint, _, endpoint_internal = endpoint.rpartition('.')
if self.blueprints and blueprint not in self.blueprints:
continue
if blueprint in self.undoc_blueprints:
continue
except ValueError:
pass # endpoint is not within a blueprint
if self.endpoints and endpoint not in self.endpoints:
continue
if endpoint in self.undoc_endpoints:
continue
try:
static_url_path = app.static_url_path # Flask 0.7 or higher
except AttributeError:
static_url_path = app.static_path # Flask 0.6 or under
if ('undoc-static' in self.options and endpoint == 'static' and
path == static_url_path + '/(path:filename)'):
continue
view = app.view_functions[endpoint]
docstring = view.__doc__ or ''
if hasattr(view, 'view_class'):
meth_func = getattr(view.view_class, method.lower(), None)
if meth_func and meth_func.__doc__:
docstring = meth_func.__doc__
if not isinstance(docstring, six.text_type):
analyzer = ModuleAnalyzer.for_module(view.__module__)
docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
docstring = prepare_docstring(docstring)
for line in http_directive(method, path, docstring):
yield line
示例5: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self, section_title_set):
# print('importing falcon app %s...' % self.arguments[0])
app = autohttp_import_object(self.arguments[0])
for method, path, handler in get_routes(app):
docstring = handler.__doc__
if not isinstance(docstring, str):
analyzer = ModuleAnalyzer.for_module(handler.__module__)
docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
# exclude falcon HTTPMethodNotAllowed endpoints
if docstring == 'Raise 405 HTTPMethodNotAllowed error':
continue
if not docstring:
continue
if hasattr(handler, '__self__'):
if not (handler.__self__.allow_read_no_auth and method == 'GET'):
docstring += '\n:reqheader Authorization: see :ref:`hmac-auth-label`.\n'
docstring = prepare_docstring(docstring)
# generate section title if needed
if path.startswith('/v'):
section_title = '/'.join(path.split('/')[0:3])
else:
section_title = path
if section_title not in section_title_set:
section_title_set.add(section_title)
yield section_title
yield '_' * len(section_title)
for line in autohttp_http_directive(method, path, docstring):
yield line
示例6: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self, section_title_set):
# print('importing falcon app %s...' % self.arguments[0])
app = autohttp_import_object(self.arguments[0])
for method, path, handler in get_routes(app):
docstring = handler.__doc__
if not isinstance(docstring, str):
analyzer = ModuleAnalyzer.for_module(handler.__module__)
docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
if not docstring:
continue
docstring = prepare_docstring(docstring)
# generate section title if needed
if path.startswith('/api'):
section_title = '/'.join(path.split('/')[0:4])
else:
section_title = path
if section_title not in section_title_set:
section_title_set.add(section_title)
yield section_title
yield '_' * len(section_title)
for line in autohttp_http_directive(method, path, docstring):
yield line
示例7: make_rst
# 需要导入模块: from sphinx import util [as 别名]
# 或者: from sphinx.util import force_decode [as 别名]
def make_rst(self):
app = import_object(self.arguments[0])
if self.endpoints:
routes = itertools.chain(*[get_routes(app, endpoint)
for endpoint in self.endpoints])
else:
routes = get_routes(app)
for method, paths, endpoint in routes:
if not self.check_regex_validate_path(paths):
continue
if self.check_regex_cancel_path(paths):
continue
try:
blueprint, _, endpoint_internal = endpoint.rpartition('.')
if self.blueprints and blueprint not in self.blueprints:
continue
if blueprint in self.undoc_blueprints:
continue
except ValueError:
pass # endpoint is not within a blueprint
if endpoint in self.undoc_endpoints:
continue
try:
static_url_path = app.static_url_path # Flask 0.7 or higher
except AttributeError:
static_url_path = app.static_path # Flask 0.6 or under
if ('undoc-static' in self.options and endpoint == 'static' and
static_url_path + '/(path:filename)' in paths):
continue
view = app.view_functions[endpoint]
docstring = view.__doc__ or ''
if hasattr(view, 'view_class'):
meth_func = getattr(view.view_class, method.lower(), None)
if meth_func and meth_func.__doc__:
docstring = meth_func.__doc__
if not isinstance(docstring, six.text_type):
analyzer = ModuleAnalyzer.for_module(view.__module__)
docstring = force_decode(docstring, analyzer.encoding)
if not docstring and 'include-empty-docstring' not in self.options:
continue
docstring = prepare_docstring(docstring)
for line in http_directive(method, paths, docstring):
yield line