Show definition for constants

Similar to the fix for functions in 1a242e5, we have to use a different
selector to query the definition for constants, "pre.const" instead of
".docblock.type-decl".
This commit is contained in:
Robin Krahl 2020-07-26 11:19:54 +02:00
parent 19398e340c
commit f0245bada3
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8
2 changed files with 5 additions and 4 deletions

View File

@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
- Improve the documentation parser:
- Fix the definition of methods to only contain the actual definition.
- Remove spurious members in module documentation.
- Show the definition for constants.
## v0.1.2 (2020-07-25)

View File

@ -129,10 +129,10 @@ fn get_example(node: &kuchiki::NodeRef) -> doc::Example {
pub fn parse_item_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
log::info!("Parsing item documentation for '{}'", item.name);
let document = parse_file(&item.path)?;
let definition_selector = if item.ty == doc::ItemType::Function {
"pre.fn"
} else {
".docblock.type-decl"
let definition_selector = match item.ty {
doc::ItemType::Constant => "pre.const",
doc::ItemType::Function => "pre.fn",
_ => ".docblock.type-decl",
};
let definition = select_first(&document, definition_selector)?;
let description = select_first(&document, "#main > .docblock:not(.type-decl)")?;