use serde::{Deserialize, Serialize};
mod docs;
mod go;
mod npm;
mod package;
mod plan;
mod python;
mod rust;
mod syntax;
mod typescript;
#[cfg(test)]
mod tests;
pub(crate) use npm::{npm_entries, npm_sources, npm_stamp};
pub use package::extract;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Kind {
Function,
Method,
Class,
Interface,
Type,
Const,
Enum,
Struct,
Trait,
Macro,
Module,
Field,
Alias,
Prose,
}
impl Kind {
pub fn as_str(self) -> &'static str {
match self {
Kind::Function => "function",
Kind::Method => "method",
Kind::Class => "class",
Kind::Interface => "interface",
Kind::Type => "type",
Kind::Const => "const",
Kind::Enum => "enum",
Kind::Struct => "struct",
Kind::Trait => "trait",
Kind::Macro => "macro",
Kind::Module => "module",
Kind::Field => "field",
Kind::Alias => "re-export",
Kind::Prose => "doc",
}
}
pub fn is_container(self) -> bool {
matches!(self, Kind::Class | Kind::Interface | Kind::Struct | Kind::Trait | Kind::Enum | Kind::Module)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Entry {
pub kind: Kind,
pub name: String,
pub path: String,
pub file: String,
pub line: u32,
pub sig: String,
pub doc: String,
pub alias_of: Option<String>,
#[serde(default)]
pub legacy: bool,
#[serde(default)]
pub prose_imports: Vec<String>,
#[serde(default)]
pub prose_parents: Vec<u32>,
}
fn entry(kind: Kind, name: &str, path: String, file: &str, line: u32, sig: String, doc: String) -> Entry {
Entry {
kind,
name: name.to_string(),
path,
file: file.to_string(),
line,
sig,
doc,
alias_of: None,
legacy: false,
prose_imports: Vec::new(),
prose_parents: Vec::new(),
}
}