mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Improve documentation
* Fix formatting in `fmt::arg` apidoc * Use production syntax instead of regex * Rename arg_field to arg_id because the term "field" denotes the whole replacement field * Define `integer`
This commit is contained in:
parent
83659f425b
commit
4325c155f7
@ -15,15 +15,18 @@ literal text, it can be escaped by doubling: ``{{`` and ``}}``.
|
|||||||
The grammar for a replacement field is as follows:
|
The grammar for a replacement field is as follows:
|
||||||
|
|
||||||
.. productionlist:: sf
|
.. productionlist:: sf
|
||||||
replacement_field: "{" [`arg_field`] [":" `format_spec`] "}"
|
replacement_field: "{" [`arg_id`] [":" `format_spec`] "}"
|
||||||
arg_field: `arg_index` | `arg_name`
|
arg_id: `integer` | `identifier`
|
||||||
arg_index: `integer`
|
integer: `digit`+
|
||||||
arg_name: \^[a-zA-Z_][a-zA-Z0-9_]*$\
|
digit: "0"..."9"
|
||||||
|
identifier: `id_start` `id_continue`*
|
||||||
|
id_start: "a"..."z" | "A"..."Z" | "_"
|
||||||
|
id_continue: `id_start` | `digit`
|
||||||
|
|
||||||
In less formal terms, the replacement field can start with an *arg_field*
|
In less formal terms, the replacement field can start with an *arg_id*
|
||||||
that specifies the argument whose value is to be formatted and inserted into
|
that specifies the argument whose value is to be formatted and inserted into
|
||||||
the output instead of the replacement field.
|
the output instead of the replacement field.
|
||||||
The *arg_field* is optionally followed by a *format_spec*, which is preceded
|
The *arg_id* is optionally followed by a *format_spec*, which is preceded
|
||||||
by a colon ``':'``. These specify a non-default format for the replacement value.
|
by a colon ``':'``. These specify a non-default format for the replacement value.
|
||||||
|
|
||||||
See also the :ref:`formatspec` section.
|
See also the :ref:`formatspec` section.
|
||||||
@ -75,8 +78,8 @@ The general form of a *standard format specifier* is:
|
|||||||
fill: <a character other than '{' or '}'>
|
fill: <a character other than '{' or '}'>
|
||||||
align: "<" | ">" | "=" | "^"
|
align: "<" | ">" | "=" | "^"
|
||||||
sign: "+" | "-" | " "
|
sign: "+" | "-" | " "
|
||||||
width: `integer` | "{" `arg_field` "}"
|
width: `integer` | "{" `arg_id` "}"
|
||||||
precision: `integer` | "{" `arg_field` "}"
|
precision: `integer` | "{" `arg_id` "}"
|
||||||
type: `int_type` | "c" | "e" | "E" | "f" | "F" | "g" | "G" | "p" | "s"
|
type: `int_type` | "c" | "e" | "E" | "f" | "F" | "g" | "G" | "p" | "s"
|
||||||
int_type: "b" | "B" | "d" | "o" | "x" | "X"
|
int_type: "b" | "B" | "d" | "o" | "x" | "X"
|
||||||
|
|
||||||
|
2
format.h
2
format.h
@ -2873,7 +2873,7 @@ void arg(WStringRef name, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFI
|
|||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
Convenient macro to capture the arguments' names and values into several
|
Convenient macro to capture the arguments' names and values into several
|
||||||
`fmt::arg(name, value)`.
|
``fmt::arg(name, value)``.
|
||||||
|
|
||||||
**Example**::
|
**Example**::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user