mirror of
https://github.com/fmtlib/fmt.git
synced 2024-09-03 21:49:01 +00:00
Improve apidoc formatting
This commit is contained in:
parent
e7ba467e9b
commit
933d8ba352
@ -1,3 +1,7 @@
|
|||||||
.docblock {
|
.docblock {
|
||||||
margin-left: 24px;
|
border-left: .05rem solid var(--md-primary-fg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.docblock-desc {
|
||||||
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
@ -2905,8 +2905,8 @@ auto vformat_to(OutputIt&& out, string_view fmt, format_args args)
|
|||||||
*
|
*
|
||||||
* **Example**:
|
* **Example**:
|
||||||
*
|
*
|
||||||
* auto out = std::vector<char>();
|
* auto out = std::vector<char>();
|
||||||
* fmt::format_to(std::back_inserter(out), "{}", 42);
|
* fmt::format_to(std::back_inserter(out), "{}", 42);
|
||||||
*/
|
*/
|
||||||
template <typename OutputIt, typename... T,
|
template <typename OutputIt, typename... T,
|
||||||
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
|
FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,
|
||||||
|
@ -57,6 +57,17 @@ def get_template_params(node: et.Element) -> Optional[list[Definition]]:
|
|||||||
params.append(param)
|
params.append(param)
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
def get_description(node: et.Element) -> list[et.Element]:
|
||||||
|
return node.findall('briefdescription/para') + \
|
||||||
|
node.findall('detaileddescription/para')
|
||||||
|
|
||||||
|
def clean_type(type: str) -> str:
|
||||||
|
type = type.replace('< ', '<').replace(' >', '>')
|
||||||
|
return type.replace(' &', '&').replace(' *', '*')
|
||||||
|
|
||||||
|
def render_type(type: str) -> str:
|
||||||
|
return type.replace("<", "<")
|
||||||
|
|
||||||
def convert_param(param: et.Element) -> Definition:
|
def convert_param(param: et.Element) -> Definition:
|
||||||
d = Definition(param.find('declname').text)
|
d = Definition(param.find('declname').text)
|
||||||
type = param.find('type')
|
type = param.find('type')
|
||||||
@ -66,9 +77,7 @@ def convert_param(param: et.Element) -> Definition:
|
|||||||
if ref.tail:
|
if ref.tail:
|
||||||
type_str += ref.tail
|
type_str += ref.tail
|
||||||
type_str += type.tail.strip()
|
type_str += type.tail.strip()
|
||||||
type_str = type_str.replace('< ', '<').replace(' >', '>')
|
d.type = clean_type(type_str)
|
||||||
type_str = type_str.replace(' &', '&').replace(' *', '*')
|
|
||||||
d.type = type_str
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
class CxxHandler(BaseHandler):
|
class CxxHandler(BaseHandler):
|
||||||
@ -145,7 +154,11 @@ class CxxHandler(BaseHandler):
|
|||||||
d.type = node.find('type').text
|
d.type = node.find('type').text
|
||||||
d.template_params = get_template_params(node)
|
d.template_params = get_template_params(node)
|
||||||
d.params = params
|
d.params = params
|
||||||
d.desc = node.findall('detaileddescription/para')
|
d.trailing_return_type = None
|
||||||
|
if d.type == 'auto':
|
||||||
|
d.trailing_return_type = clean_type(
|
||||||
|
node.find('argsstring').text.split(' -> ')[1])
|
||||||
|
d.desc = get_description(node)
|
||||||
return d
|
return d
|
||||||
cls = self._doxyxml.findall(f"compounddef/innerclass[.='fmt::{name}']")
|
cls = self._doxyxml.findall(f"compounddef/innerclass[.='fmt::{name}']")
|
||||||
if not cls:
|
if not cls:
|
||||||
@ -157,7 +170,7 @@ class CxxHandler(BaseHandler):
|
|||||||
d.type = node.get('kind')
|
d.type = node.get('kind')
|
||||||
d.template_params = get_template_params(node)
|
d.template_params = get_template_params(node)
|
||||||
d.params = None
|
d.params = None
|
||||||
d.desc = node.findall('detaileddescription/para')
|
d.desc = get_description(node)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def render(self, d: Definition, config: dict) -> str:
|
def render(self, d: Definition, config: dict) -> str:
|
||||||
@ -171,8 +184,10 @@ class CxxHandler(BaseHandler):
|
|||||||
text += d.type + ' ' + d.name
|
text += d.type + ' ' + d.name
|
||||||
if d.params is not None:
|
if d.params is not None:
|
||||||
params = ', '.join(
|
params = ', '.join(
|
||||||
[f'{p.type.replace("<", "<")} {p.name}' for p in d.params])
|
[f'{render_type(p.type)} {p.name}' for p in d.params])
|
||||||
text += '(' + params + ')'
|
text += '(' + params + ')'
|
||||||
|
if d.trailing_return_type:
|
||||||
|
text += ' -> ' + render_type(d.trailing_return_type)
|
||||||
text += ';'
|
text += ';'
|
||||||
text += '</code></pre>\n'
|
text += '</code></pre>\n'
|
||||||
text += '<div class="docblock-desc">\n'
|
text += '<div class="docblock-desc">\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user