Fix definition selector for functions

Previosuly, we always used the selector ".docblock.type-decl" to select
the definition for an item.  But this did not work for functions.
Therefore we change the selector to "pre.fn" for functions.
This commit is contained in:
Robin Krahl 2020-07-25 12:18:32 +02:00
parent 221c345e1c
commit 1a242e5474
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8
2 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ SPDX-License-Identifier: MIT
environment variable `RUST_LOG=info`.
- Add `env_logger` dependency in version 0.7.1.
- Add `log` dependency in version 0.4.11.
- Show the definition for global functions.
# v0.1.1 (2020-07-24)

View File

@ -79,7 +79,12 @@ fn select_first(
pub fn parse_item_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
let document = parse_file(&item.path)?;
let definition = select_first(&document, ".docblock.type-decl")?;
let definition_selector = if item.ty == doc::ItemType::Function {
"pre.fn"
} else {
".docblock.type-decl"
};
let definition = select_first(&document, definition_selector)?;
let description = select_first(&document, "#main > .docblock:not(.type-decl)")?;
let mut doc = doc::Doc::new(item.name.clone(), item.ty);