Add more log messages
As I noticed when trying to debug an issue with a very large HTML file, we still need more log messages that indicate what is currently going on in rusty-man. This patch adds some more log messages.
This commit is contained in:
parent
34857816e1
commit
e9aafd4650
@ -387,6 +387,7 @@ impl Crate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_item(&self, name: &Fqn) -> anyhow::Result<Option<Item>> {
|
pub fn find_item(&self, name: &Fqn) -> anyhow::Result<Option<Item>> {
|
||||||
|
log::info!("Searching item '{}' in crate '{}'", name, self.name);
|
||||||
if self.name == name.krate() {
|
if self.name == name.krate() {
|
||||||
if let Some(local_name) = name.rest() {
|
if let Some(local_name) = name.rest() {
|
||||||
if let Some(path) = parser::find_item(self.path.join("all.html"), local_name)? {
|
if let Some(path) = parser::find_item(self.path.join("all.html"), local_name)? {
|
||||||
@ -405,6 +406,7 @@ impl Crate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_module(&self, name: &Fqn) -> Option<Item> {
|
pub fn find_module(&self, name: &Fqn) -> Option<Item> {
|
||||||
|
log::info!("Searching module '{}' in crate '{}'", name, self.name);
|
||||||
if self.name == name.krate() {
|
if self.name == name.krate() {
|
||||||
let module_path = if let Some(rest) = name.rest() {
|
let module_path = if let Some(rest) = name.rest() {
|
||||||
rest.split("::").fold(path::PathBuf::new(), |mut p, s| {
|
rest.split("::").fold(path::PathBuf::new(), |mut p, s| {
|
||||||
@ -426,6 +428,7 @@ impl Crate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_member(&self, name: &Fqn) -> Option<Item> {
|
pub fn find_member(&self, name: &Fqn) -> Option<Item> {
|
||||||
|
log::info!("Searching member '{}' in crate '{}'", name, self.name);
|
||||||
if let Some(parent) = name.parent() {
|
if let Some(parent) = name.parent() {
|
||||||
// TODO: error
|
// TODO: error
|
||||||
self.find_item(&parent)
|
self.find_item(&parent)
|
||||||
@ -443,6 +446,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_doc(&self) -> anyhow::Result<Doc> {
|
pub fn load_doc(&self) -> anyhow::Result<Doc> {
|
||||||
|
log::info!("Loading documentation for '{}'", self.name);
|
||||||
match self.ty {
|
match self.ty {
|
||||||
ItemType::TyMethod
|
ItemType::TyMethod
|
||||||
| ItemType::Method
|
| ItemType::Method
|
||||||
@ -456,6 +460,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_member(&self, name: &Fqn) -> Option<Item> {
|
pub fn find_member(&self, name: &Fqn) -> Option<Item> {
|
||||||
|
log::info!("Searching member '{}' in item '{}'", name, self.name);
|
||||||
// TODO: error handling
|
// TODO: error handling
|
||||||
parser::find_member(&self.path, name).unwrap()
|
parser::find_member(&self.path, name).unwrap()
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,13 @@ use crate::doc;
|
|||||||
fn parse_file<P: AsRef<path::Path>>(path: P) -> anyhow::Result<kuchiki::NodeRef> {
|
fn parse_file<P: AsRef<path::Path>>(path: P) -> anyhow::Result<kuchiki::NodeRef> {
|
||||||
use kuchiki::traits::TendrilSink;
|
use kuchiki::traits::TendrilSink;
|
||||||
|
|
||||||
kuchiki::parse_html()
|
log::info!("Reading HTML from file '{}'", path.as_ref().display());
|
||||||
|
let result = kuchiki::parse_html()
|
||||||
.from_utf8()
|
.from_utf8()
|
||||||
.from_file(path)
|
.from_file(path)
|
||||||
.context("Could not read HTML file")
|
.context("Could not read HTML file");
|
||||||
|
log::info!("HTML file parsed successfully");
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_string(s: impl Into<String>) -> anyhow::Result<kuchiki::NodeRef> {
|
fn parse_string(s: impl Into<String>) -> anyhow::Result<kuchiki::NodeRef> {
|
||||||
@ -108,6 +111,7 @@ fn get_example(node: &kuchiki::NodeRef) -> doc::Example {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_item_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
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 document = parse_file(&item.path)?;
|
||||||
let definition_selector = if item.ty == doc::ItemType::Function {
|
let definition_selector = if item.ty == doc::ItemType::Function {
|
||||||
"pre.fn"
|
"pre.fn"
|
||||||
@ -162,6 +166,7 @@ const MODULE_MEMBER_TYPES: &[doc::ItemType] = &[
|
|||||||
];
|
];
|
||||||
|
|
||||||
pub fn parse_module_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
pub fn parse_module_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
||||||
|
log::info!("Parsing module documentation for '{}'", item.name);
|
||||||
let document = parse_file(&item.path)?;
|
let document = parse_file(&item.path)?;
|
||||||
let description = select_first(&document, ".docblock")?;
|
let description = select_first(&document, ".docblock")?;
|
||||||
|
|
||||||
@ -178,6 +183,7 @@ pub fn parse_module_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_member_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
pub fn parse_member_doc(item: &doc::Item) -> anyhow::Result<doc::Doc> {
|
||||||
|
log::info!("Parsing member documentation for '{}'", item.name);
|
||||||
let document = parse_file(&item.path)?;
|
let document = parse_file(&item.path)?;
|
||||||
let member = get_member(&document, item.name.last())?
|
let member = get_member(&document, item.name.last())?
|
||||||
.with_context(|| format!("Could not find member {}", &item.name))?;
|
.with_context(|| format!("Could not find member {}", &item.name))?;
|
||||||
|
@ -36,15 +36,23 @@ impl DirSource {
|
|||||||
|
|
||||||
impl Source for DirSource {
|
impl Source for DirSource {
|
||||||
fn find_crate(&self, name: &str) -> Option<doc::Crate> {
|
fn find_crate(&self, name: &str) -> Option<doc::Crate> {
|
||||||
|
log::info!(
|
||||||
|
"Searching crate '{}' in dir source '{}'",
|
||||||
|
name,
|
||||||
|
self.path.display()
|
||||||
|
);
|
||||||
let crate_path = self.path.join(name.replace('-', "_"));
|
let crate_path = self.path.join(name.replace('-', "_"));
|
||||||
if crate_path.join("all.html").is_file() {
|
if crate_path.join("all.html").is_file() {
|
||||||
|
log::info!("Found crate '{}': '{}'", name, crate_path.display());
|
||||||
Some(doc::Crate::new(name.to_owned(), crate_path))
|
Some(doc::Crate::new(name.to_owned(), crate_path))
|
||||||
} else {
|
} else {
|
||||||
|
log::info!("Did not find crate '{}' in '{}'", name, self.path.display());
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_index(&self) -> anyhow::Result<Option<index::Index>> {
|
fn load_index(&self) -> anyhow::Result<Option<index::Index>> {
|
||||||
|
log::info!("Searching search index for '{}'", self.path.display());
|
||||||
// use the first file that matches the pattern search-index*.js
|
// use the first file that matches the pattern search-index*.js
|
||||||
for entry in fs::read_dir(&self.path)? {
|
for entry in fs::read_dir(&self.path)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
Loading…
Reference in New Issue
Block a user