Skip to content

Commit

Permalink
remove overloads from member functions list and just show their count
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Feb 19, 2023
1 parent d5b9067 commit 6651779
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ impl<'e> Builder<'e> {
&self.config.output_dir.join("functions.json"),
serde_json::to_string(
&self.root.nav().suboptions_titles(self.config.clone())
.into_iter()
.map(|(n, c)| if c > 0 { format!("{} ({})", n, c + 1) } else { n })
.collect::<Vec<_>>()
).map_err(|e| format!("Unable to save metadata {e}"))?
).map_err(|e| format!("Unable to save metadata {e}"))?;

Expand Down
22 changes: 15 additions & 7 deletions src/builder/traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clang::{Entity, EntityKind, Accessibility};

use std::{path::PathBuf, sync::Arc};
use std::{path::PathBuf, sync::Arc, collections::HashMap};

use tokio::task::JoinHandle;

Expand Down Expand Up @@ -205,17 +205,25 @@ impl NavItem {
NavItem::Root(name.map(|s| s.into()), items)
}

pub fn suboptions_titles(&self, config: Arc<Config>) -> Vec<String> {
pub fn suboptions_titles(&self, config: Arc<Config>) -> HashMap<String, usize> {
match self {
NavItem::Link(name, _, _, suboptions) => suboptions.clone()
.into_iter()
.map(|o| format!("{}::{}", name, o.title))
.collect(),
NavItem::Link(name, _, _, suboptions) => {
let mut res = HashMap::new();
for opt in suboptions.iter().map(|o| format!("{}::{}", name, o.title)) {
if let Some(r) = res.get_mut(&opt) {
*r += 1;
}
else {
res.insert(opt, 0);
}
}
res
},

NavItem::Dir(name, items, _, _) => items.iter()
.flat_map(|i| i.suboptions_titles(config.clone()))
.into_iter()
.map(|t| format!("{}::{}", name, t))
.map(|(t, count)| (format!("{}::{}", name, t), count))
.collect(),

NavItem::Root(_, items) => items.iter()
Expand Down
2 changes: 1 addition & 1 deletion templates/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function updateNav() {
const match = furryMatchMany([name], searchQuery, '::');
if (match) {
const node = document.createElement('a');
const url = `${FLASH_OUTPUT_URL}/classes/${f.join('/')}#${name}`;
const url = `${FLASH_OUTPUT_URL}/classes/${f.join('/')}#${name.replace(/\s+\([0-9]+\)/, '')}`;
node.setAttribute('href', url);
node.addEventListener('click', e => {
navigate(url);
Expand Down

0 comments on commit 6651779

Please sign in to comment.