Properly display constructor arguments documentation, if any.
This commit is contained in:
parent
2bb2f11090
commit
802e8272c5
|
@ -553,6 +553,15 @@ struct DocTypeConstructor {
|
||||||
|
|
||||||
impl DocTypeConstructor {
|
impl DocTypeConstructor {
|
||||||
fn from_record_constructor(constructor: &RecordConstructor<Rc<Type>>) -> Self {
|
fn from_record_constructor(constructor: &RecordConstructor<Rc<Type>>) -> Self {
|
||||||
|
let doc_args = constructor
|
||||||
|
.arguments
|
||||||
|
.iter()
|
||||||
|
.filter_map(|arg| match (arg.label.as_deref(), arg.doc.as_deref()) {
|
||||||
|
(Some(label), Some(doc)) => Some(format!("#### `.{label}`\n{doc}\n<hr/>\n",)),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
DocTypeConstructor {
|
DocTypeConstructor {
|
||||||
definition: format::Formatter::new()
|
definition: format::Formatter::new()
|
||||||
.docs_record_constructor(constructor)
|
.docs_record_constructor(constructor)
|
||||||
|
@ -560,7 +569,7 @@ impl DocTypeConstructor {
|
||||||
documentation: constructor
|
documentation: constructor
|
||||||
.doc
|
.doc
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(render_markdown)
|
.map(|doc| render_markdown(&format!("{doc}\n{doc_args}")))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
raw_documentation: constructor.doc.as_deref().unwrap_or_default().to_string(),
|
raw_documentation: constructor.doc.as_deref().unwrap_or_default().to_string(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,10 +510,32 @@ body.drawer-open .label-closed {
|
||||||
color: var(--color-background-accent);
|
color: var(--color-background-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.constructor-item-docs hr {
|
||||||
|
color: var(--color-text-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.constructor-item-docs hr:last-child {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.constructor-item-docs p {
|
.constructor-item-docs p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.constructor-item-docs h4 {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.constructor-item-docs h4 > code {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.constructor-item-docs h4 ~ p {
|
||||||
|
padding-left: 0.5rem;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.constructor-name {
|
.constructor-name {
|
||||||
box-shadow: unset;
|
box-shadow: unset;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
Loading…
Reference in New Issue