mirror of
https://github.com/fmtlib/fmt.git
synced 2024-09-15 15:13:22 +00:00
Improve apidoc formatting
This commit is contained in:
parent
91a859ee4a
commit
e7ba467e9b
@ -1,4 +1,4 @@
|
|||||||
# API Reference {#string-formatting-api}
|
# API Reference
|
||||||
|
|
||||||
The {fmt} library API consists of the following parts:
|
The {fmt} library API consists of the following parts:
|
||||||
|
|
||||||
@ -55,12 +55,8 @@ specified otherwise.
|
|||||||
<a id="print"></a>
|
<a id="print"></a>
|
||||||
::: print(format_string<T...>, T&&...)
|
::: print(format_string<T...>, T&&...)
|
||||||
|
|
||||||
::: vprint(string_view, format_args)
|
|
||||||
|
|
||||||
::: print(FILE*, format_string<T...>, T&&...)
|
::: print(FILE*, format_string<T...>, T&&...)
|
||||||
|
|
||||||
::: vprint(FILE*, string_view, format_args)
|
|
||||||
|
|
||||||
::: println(format_string<T...>, T&&...)
|
::: println(format_string<T...>, T&&...)
|
||||||
|
|
||||||
::: println(FILE*, format_string<T...>, T&&...)
|
::: println(FILE*, format_string<T...>, T&&...)
|
||||||
@ -90,7 +86,8 @@ fmt::format_string
|
|||||||
|
|
||||||
::: runtime(string_view)
|
::: runtime(string_view)
|
||||||
|
|
||||||
### Formatting User-Defined Types {#udt}
|
<a id="udt"></a>
|
||||||
|
### Formatting User-Defined Types
|
||||||
|
|
||||||
The {fmt} library provides formatters for many standard C++ types.
|
The {fmt} library provides formatters for many standard C++ types.
|
||||||
See [`fmt/ranges.h`](#ranges-api) for ranges and tuples including standard
|
See [`fmt/ranges.h`](#ranges-api) for ranges and tuples including standard
|
||||||
|
@ -46,11 +46,11 @@ def doxyxml2html(nodes: list[et.Element]):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
def get_template_params(node: et.Element) -> Optional[list[Definition]]:
|
def get_template_params(node: et.Element) -> Optional[list[Definition]]:
|
||||||
param_nodes = node.findall('templateparamlist/param')
|
templateparamlist = node.find('templateparamlist')
|
||||||
if param_nodes is None:
|
if templateparamlist is None:
|
||||||
return None
|
return None
|
||||||
params = []
|
params = []
|
||||||
for param_node in param_nodes:
|
for param_node in templateparamlist.findall('param'):
|
||||||
name = param_node.find('declname')
|
name = param_node.find('declname')
|
||||||
param = Definition(name.text if name is not None else '')
|
param = Definition(name.text if name is not None else '')
|
||||||
param.type = param_node.find('type').text
|
param.type = param_node.find('type').text
|
||||||
@ -161,10 +161,12 @@ class CxxHandler(BaseHandler):
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def render(self, d: Definition, config: dict) -> str:
|
def render(self, d: Definition, config: dict) -> str:
|
||||||
text = '<pre><code>'
|
text = '<div class="docblock">\n'
|
||||||
|
text += '<pre><code>'
|
||||||
if d.template_params is not None:
|
if d.template_params is not None:
|
||||||
text += 'template <'
|
text += 'template <'
|
||||||
text += ', '.join([f'{p.type} {p.name}' for p in d.template_params])
|
text += ', '.join(
|
||||||
|
[f'{p.type} {p.name}'.rstrip() for p in d.template_params])
|
||||||
text += '>\n'
|
text += '>\n'
|
||||||
text += d.type + ' ' + d.name
|
text += d.type + ' ' + d.name
|
||||||
if d.params is not None:
|
if d.params is not None:
|
||||||
@ -173,10 +175,11 @@ class CxxHandler(BaseHandler):
|
|||||||
text += '(' + params + ')'
|
text += '(' + params + ')'
|
||||||
text += ';'
|
text += ';'
|
||||||
text += '</code></pre>\n'
|
text += '</code></pre>\n'
|
||||||
text += '<div class="docblock">\n'
|
text += '<div class="docblock-desc">\n'
|
||||||
desc = doxyxml2html(d.desc)
|
desc = doxyxml2html(d.desc)
|
||||||
text += desc
|
text += desc
|
||||||
text += '</div>\n'
|
text += '</div>\n'
|
||||||
|
text += '</div>\n'
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def get_handler(theme: str, custom_templates: Optional[str] = None,
|
def get_handler(theme: str, custom_templates: Optional[str] = None,
|
||||||
|
Loading…
Reference in New Issue
Block a user