mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Emit anchors
This commit is contained in:
12
doc/api.md
12
doc/api.md
@ -10,7 +10,7 @@ The {fmt} library API consists of the following components:
|
|||||||
- [`fmt/chrono.h`](#chrono-api): date and time formatting
|
- [`fmt/chrono.h`](#chrono-api): date and time formatting
|
||||||
- [`fmt/std.h`](#std-api): formatters for standard library types
|
- [`fmt/std.h`](#std-api): formatters for standard library types
|
||||||
- [`fmt/compile.h`](#compile-api): format string compilation
|
- [`fmt/compile.h`](#compile-api): format string compilation
|
||||||
- [`fmt/color.h`](#color-api): terminal color and text style
|
- [`fmt/color.h`](#color-api): terminal colors and text styles
|
||||||
- [`fmt/os.h`](#os-api): system APIs
|
- [`fmt/os.h`](#os-api): system APIs
|
||||||
- [`fmt/ostream.h`](#ostream-api): `std::ostream` support
|
- [`fmt/ostream.h`](#ostream-api): `std::ostream` support
|
||||||
- [`fmt/args.h`](#args-api): dynamic argument lists
|
- [`fmt/args.h`](#args-api): dynamic argument lists
|
||||||
@ -394,7 +394,7 @@ allocator:
|
|||||||
}
|
}
|
||||||
|
|
||||||
The allocator will be used for the output container only. Formatting
|
The allocator will be used for the output container only. Formatting
|
||||||
functions normally don\'t do any allocations for built-in and string
|
functions normally don't do any allocations for built-in and string
|
||||||
types except for non-default floating-point formatting that occasionally
|
types except for non-default floating-point formatting that occasionally
|
||||||
falls back on `sprintf`.
|
falls back on `sprintf`.
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ performance bottleneck.
|
|||||||
::: operator""_cf
|
::: operator""_cf
|
||||||
|
|
||||||
<a id="color-api"></a>
|
<a id="color-api"></a>
|
||||||
## Terminal Color and Text Style
|
## Terminal Colors and Text Styles
|
||||||
|
|
||||||
`fmt/color.h` provides support for terminal color and text style output.
|
`fmt/color.h` provides support for terminal color and text style output.
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ functionality. The following functions use [printf format string
|
|||||||
syntax](https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html)
|
syntax](https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html)
|
||||||
with the POSIX extension for positional arguments. Unlike their standard
|
with the POSIX extension for positional arguments. Unlike their standard
|
||||||
counterparts, the `fmt` functions are type-safe and throw an exception
|
counterparts, the `fmt` functions are type-safe and throw an exception
|
||||||
if an argument type doesn\'t match its format specification.
|
if an argument type doesn't match its format specification.
|
||||||
|
|
||||||
::: printf(string_view, const T&...)
|
::: printf(string_view, const T&...)
|
||||||
|
|
||||||
@ -647,5 +647,5 @@ following differences:
|
|||||||
|
|
||||||
- Names are defined in the `fmt` namespace instead of `std` to avoid
|
- Names are defined in the `fmt` namespace instead of `std` to avoid
|
||||||
collisions with standard library implementations.
|
collisions with standard library implementations.
|
||||||
- Width calculation doesn\'t use grapheme clusterization. The latter has
|
- Width calculation doesn't use grapheme clusterization. The latter has
|
||||||
been implemented in a separate branch but hasn\'t been integrated yet.
|
been implemented in a separate branch but hasn't been integrated yet.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Format String Syntax
|
# Format String Syntax
|
||||||
|
|
||||||
[Formatting functions](api.md) such as `fmt::format` and `fmt::print` use the
|
[Formatting functions](api.md) such as `fmt::format` and [`fmt::print`](
|
||||||
same format string syntax described in this section.
|
api.md#print) use the same format string syntax described in this section.
|
||||||
|
|
||||||
Format strings contain "replacement fields" surrounded by curly braces `{}`.
|
Format strings contain "replacement fields" surrounded by curly braces `{}`.
|
||||||
Anything that is not contained in braces is considered literal text, which is
|
Anything that is not contained in braces is considered literal text, which is
|
||||||
|
@ -9,9 +9,11 @@ from subprocess import CalledProcessError, PIPE, Popen, STDOUT
|
|||||||
|
|
||||||
class Definition:
|
class Definition:
|
||||||
'''A definition extracted by Doxygen.'''
|
'''A definition extracted by Doxygen.'''
|
||||||
def __init__(self, name: str, kind: str):
|
def __init__(self, name: str, kind: Optional[str] = None,
|
||||||
|
node: Optional[et.Element] = None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.kind = kind
|
self.kind = kind if kind is not None else node.get('kind')
|
||||||
|
self.id = node.get('id') if node is not None else None
|
||||||
self.params = None
|
self.params = None
|
||||||
self.members = None
|
self.members = None
|
||||||
|
|
||||||
@ -99,7 +101,10 @@ def convert_return_type(d: Definition, node: et.Element) -> None:
|
|||||||
d.trailing_return_type = normalize_type(parts[1])
|
d.trailing_return_type = normalize_type(parts[1])
|
||||||
|
|
||||||
def render_decl(d: Definition) -> None:
|
def render_decl(d: Definition) -> None:
|
||||||
text = '<pre><code class="language-cpp">'
|
text = ''
|
||||||
|
if d.id is not None:
|
||||||
|
text += f'<a id="{d.id}">\n'
|
||||||
|
text += '<pre><code class="language-cpp">'
|
||||||
|
|
||||||
if d.template_params is not None:
|
if d.template_params is not None:
|
||||||
text += 'template <'
|
text += 'template <'
|
||||||
@ -131,6 +136,8 @@ def render_decl(d: Definition) -> None:
|
|||||||
|
|
||||||
text += end
|
text += end
|
||||||
text += '</code></pre>\n'
|
text += '</code></pre>\n'
|
||||||
|
if d.id is not None:
|
||||||
|
text += f'</a>\n'
|
||||||
return text
|
return text
|
||||||
|
|
||||||
class CxxHandler(BaseHandler):
|
class CxxHandler(BaseHandler):
|
||||||
@ -203,7 +210,7 @@ class CxxHandler(BaseHandler):
|
|||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
xml = et.parse(f)
|
xml = et.parse(f)
|
||||||
node = xml.find('compounddef')
|
node = xml.find('compounddef')
|
||||||
d = Definition(identifier, node.get('kind'))
|
d = Definition(identifier, node=node)
|
||||||
d.template_params = convert_template_params(node)
|
d.template_params = convert_template_params(node)
|
||||||
d.desc = get_description(node)
|
d.desc = get_description(node)
|
||||||
d.members = []
|
d.members = []
|
||||||
@ -257,20 +264,19 @@ class CxxHandler(BaseHandler):
|
|||||||
for node in nodes:
|
for node in nodes:
|
||||||
# Process a function or a typedef.
|
# Process a function or a typedef.
|
||||||
params = None
|
params = None
|
||||||
kind = node.get('kind')
|
d = Definition(name, node=node)
|
||||||
if kind == 'function':
|
if d.kind == 'function':
|
||||||
params = convert_params(node)
|
params = convert_params(node)
|
||||||
node_param_str = ', '.join([p.type for p in params])
|
node_param_str = ', '.join([p.type for p in params])
|
||||||
if param_str and param_str != node_param_str:
|
if param_str and param_str != node_param_str:
|
||||||
candidates.append(f'{name}({node_param_str})')
|
candidates.append(f'{name}({node_param_str})')
|
||||||
continue
|
continue
|
||||||
elif kind == 'define':
|
elif d.kind == 'define':
|
||||||
params = []
|
params = []
|
||||||
for p in node.findall('param'):
|
for p in node.findall('param'):
|
||||||
d = Definition(p.find('defname').text, 'param')
|
d = Definition(p.find('defname').text, 'param')
|
||||||
d.type = None
|
d.type = None
|
||||||
params.append(d)
|
params.append(d)
|
||||||
d = Definition(name, kind)
|
|
||||||
d.type = convert_type(node.find('type'))
|
d.type = convert_type(node.find('type'))
|
||||||
d.template_params = convert_template_params(node)
|
d.template_params = convert_template_params(node)
|
||||||
d.params = params
|
d.params = params
|
||||||
|
Reference in New Issue
Block a user