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:
parent
221c345e1c
commit
1a242e5474
@ -9,6 +9,7 @@ SPDX-License-Identifier: MIT
|
|||||||
environment variable `RUST_LOG=info`.
|
environment variable `RUST_LOG=info`.
|
||||||
- Add `env_logger` dependency in version 0.7.1.
|
- Add `env_logger` dependency in version 0.7.1.
|
||||||
- Add `log` dependency in version 0.4.11.
|
- Add `log` dependency in version 0.4.11.
|
||||||
|
- Show the definition for global functions.
|
||||||
|
|
||||||
# v0.1.1 (2020-07-24)
|
# v0.1.1 (2020-07-24)
|
||||||
|
|
||||||
|
@ -79,7 +79,12 @@ fn select_first(
|
|||||||
|
|
||||||
pub fn parse_item_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
pub fn parse_item_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
||||||
let document = parse_file(&item.path)?;
|
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 description = select_first(&document, "#main > .docblock:not(.type-decl)")?;
|
||||||
|
|
||||||
let mut doc = doc::Doc::new(item.name.clone(), item.ty);
|
let mut doc = doc::Doc::new(item.name.clone(), item.ty);
|
||||||
|
Loading…
Reference in New Issue
Block a user