Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Fork #1

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
8e6dfc2
fix(html): correctly handle examples in document navigation (#612)
crowlKats Jul 12, 2024
80ca340
0.143.0
denobot Jul 12, 2024
4fbd014
perf(html): initialize ammonia once, faster anchorizer, reduce iter c…
crowlKats Jul 23, 2024
fe93d09
feat(html): rework category panel and notes (#617)
crowlKats Jul 24, 2024
79fb988
0.144.0
denobot Jul 24, 2024
13f6b8d
perf: deno_ast 0.41 (#619)
dsherret Jul 31, 2024
182d76c
0.145.0
denobot Jul 31, 2024
4123592
fix(html): better titles and correct breadcrumbs (#620)
crowlKats Aug 5, 2024
584fd49
chore: upgrade deps (#621)
ry Aug 5, 2024
88dd94c
feat(html): external jsdoc module linking (#622)
crowlKats Aug 8, 2024
b14e8ad
0.146.0
denobot Aug 8, 2024
c9af343
feat(html): extract JSDoc summary/title from jsdoc body (#623)
crowlKats Aug 28, 2024
b6612a6
0.147.0
denobot Aug 28, 2024
e31f285
fix: deno_ast 0.42 (#624)
dsherret Aug 30, 2024
7bd0530
0.148.0
denobot Aug 30, 2024
b54b558
feat: hide lines in codeblocks starting with `# ` (#629)
crowlKats Sep 14, 2024
739290b
test: separate test case which require sanitizer disabled (#628)
kt3k Sep 14, 2024
9261997
feat(html): render @see tags (#627)
crowlKats Sep 16, 2024
ddceffb
0.149.0
denobot Sep 17, 2024
f196eaa
fix(html): proper tag order (#630)
crowlKats Sep 25, 2024
93f4ce3
chore: update formatting for canary (#632)
dsherret Sep 25, 2024
697b803
feat(html): show method and properties of classes under classes on sy…
crowlKats Sep 25, 2024
d3beb21
0.150.0
denobot Sep 26, 2024
75a8fff
fix: ensure safe text slicing boundaries with multi-byte characters (…
MujahedSafaa Sep 26, 2024
140de9a
chore: deno_graph 0.83 (#637)
nayeemrmn Sep 26, 2024
df2b9d4
0.150.1
denobot Sep 26, 2024
4e47d58
feat: support module tag value & use for specifying identifier in usa…
crowlKats Oct 1, 2024
44dd960
feat(html): remove composable_output option (#638)
crowlKats Oct 3, 2024
56fb503
fix: make ts_type and ts_type_param pub (#640)
crowlKats Oct 4, 2024
b69fb0e
fix(html): better identifier for default exported symbols (#642)
crowlKats Oct 7, 2024
ab06885
feat(html): render throws tag (#639)
crowlKats Oct 7, 2024
e984672
feat: add drilldowns to search (#643)
crowlKats Oct 8, 2024
5969d5b
chore: update tree-sitter, and add xml / dtd (#614)
lucacasonato Oct 8, 2024
b974953
fix: better handle cross-symbol links on all symbols page (#641)
crowlKats Oct 8, 2024
4e5275d
0.151.0
denobot Oct 8, 2024
e917e0b
feat: use only tree-sitter (#644)
crowlKats Oct 8, 2024
00f451d
0.152.0
denobot Oct 8, 2024
e701be4
chore: update setup-deno (#645)
crowlKats Oct 9, 2024
3aee62c
fix(html): store original name of methods (#646)
crowlKats Oct 9, 2024
3337daa
0.153.0
denobot Oct 9, 2024
3f41a99
fix: re-add syntect (#648)
crowlKats Oct 16, 2024
b4fe44f
0.154.0
denobot Oct 16, 2024
5710ffb
fix(html): add fallback for search if filename is invalid (#650)
crowlKats Oct 24, 2024
142b14b
0.154.1
denobot Oct 24, 2024
28a6c15
perf(html): less allocations for search and smaller search struct (#651)
crowlKats Oct 25, 2024
17b4603
0.155.0
denobot Oct 25, 2024
2519261
refactor: handle using program instead of module (#649)
dsherret Oct 28, 2024
8923ce0
0.156.0
denobot Oct 28, 2024
f26eb97
fix(html): always show example content, enable ammonia by default, an…
crowlKats Nov 5, 2024
b43dd22
refactor(html): extract and isolate markdown rendering (#656)
crowlKats Nov 8, 2024
ea552e0
feat: add feedback on copy (#652)
mbhrznr Nov 8, 2024
473fd6a
feat(html): allow overwriting the file identifier for usages (#657)
crowlKats Nov 8, 2024
f8b8d8b
0.157.0
denobot Nov 8, 2024
53c86dd
feat: support html generation via Wasm (#658)
crowlKats Nov 15, 2024
c8b849b
0.158.0
denobot Nov 15, 2024
751e6e4
feat(wasm/html): add callback to generate the default path resolver i…
crowlKats Nov 15, 2024
04a7df0
0.159.0
denobot Nov 15, 2024
daf3433
chore: expose `ComrakHighlightWrapperAdapter` (#661)
crowlKats Nov 16, 2024
d3b8032
0.159.1
denobot Nov 16, 2024
a799d66
chore: make ComrakHighlightWrapperAdapter field pub (#662)
crowlKats Nov 18, 2024
ce59a22
0.159.2
denobot Nov 18, 2024
7022bf4
feat: Wasm support (#653)
dsherret Nov 18, 2024
b6f46ad
fix: downgrade url dep (#663)
crowlKats Nov 19, 2024
5da06d1
0.160.0
denobot Nov 19, 2024
c4da783
docs: update examples in js/README.md (#664)
kt3k Nov 20, 2024
6446349
refactor: remove ammonia and additional comrak features (#665)
crowlKats Nov 22, 2024
fb289ce
0.161.0
denobot Nov 22, 2024
ba56867
fix: upgrade to deno_graph 0.86 (#667)
dsherret Nov 26, 2024
6969d7b
0.161.1
denobot Nov 26, 2024
e012877
chore: upgrade deno_ast and deno_graph (#670)
bartlomieju Nov 26, 2024
3e9d705
0.161.2
denobot Nov 26, 2024
38c0451
add documentation for html development (#672)
crowlKats Nov 28, 2024
1169db5
chore: create import map for dependencies (#668)
BlackAsLight Nov 29, 2024
9f5fdd7
chore: update itoa dep (#677)
crowlKats Dec 13, 2024
9cf98e2
0.161.3
denobot Dec 13, 2024
c5f9f15
feat: node references (#674)
crowlKats Dec 16, 2024
fbc0b77
0.162.0
denobot Dec 16, 2024
0de7406
fix(html): recursively update ns_qualifiers when resolving a referenc…
crowlKats Dec 16, 2024
437f27c
0.162.1
denobot Dec 16, 2024
f8a13d3
testing: code coverage and more exhaustive tests (#679)
crowlKats Dec 19, 2024
d385a9f
fix: add temporary fallbacks for reference resolution (#682)
crowlKats Dec 20, 2024
bd068c4
0.162.2
denobot Dec 20, 2024
f5eeb2e
chore: fix publish (#683)
crowlKats Dec 20, 2024
2c0ff7c
0.162.3
denobot Dec 20, 2024
3fe2842
chore: update deno_path_util (#684)
dsherret Dec 27, 2024
6553991
0.162.4
denobot Dec 27, 2024
f559dbe
feat(html): allow generating JSON representation of HTML output (#686)
crowlKats Jan 4, 2025
5e035ef
0.163.0
denobot Jan 4, 2025
92b3052
chore: update deps (#688)
crowlKats Jan 8, 2025
46e4586
0.164.0
denobot Jan 8, 2025
25e789a
feat(html): expose raw document navigation for json output (#689)
crowlKats Jan 16, 2025
4258a05
0.165.0
denobot Jan 16, 2025
e3fa70e
feat: add typings for htmlAsJSON (#692)
crowlKats Jan 24, 2025
fd7fa63
0.166.0
denobot Jan 24, 2025
697d274
fix: show private symbols in dts files (#693)
crowlKats Jan 27, 2025
8f80891
0.167.0
denobot Jan 27, 2025
90c8f00
refactor: pass EsModuleInfo instead of ParsedSource around (#695)
crowlKats Jan 28, 2025
6d6209b
refactor: remove `DocNodeKind` (#696)
crowlKats Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: handle using program instead of module (denoland#649)
dsherret authored Oct 28, 2024
commit 251926175e7a294cf336de6e48d66927ab6bbe9f
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ repository = "https://github.com/denoland/deno_doc"
members = ["lib"]

[workspace.dependencies]
deno_graph = { version = "0.83.0", default-features = false, features = ["symbols"] }
deno_ast = { version = "0.42.0" }
deno_graph = { version = "0.84.0", default-features = false, features = ["symbols"] }
deno_ast = { version = "0.43.0" }
import_map = "0.20.0"
serde = { version = "1.0.204", features = ["derive"] }

99 changes: 48 additions & 51 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

use crate::diagnostics::DiagnosticsCollector;
use crate::diagnostics::DocDiagnostic;
use crate::js_doc::JsDoc;
use crate::node;
use crate::node::DeclarationKind;
use crate::node::DocNode;
use crate::node::ModuleDoc;
use crate::node::NamespaceDef;
use crate::ts_type::infer_simple_ts_type_from_init;
use crate::ts_type::PropertyDef;
use crate::ts_type::TsTypeDef;
use crate::ts_type::TsTypeDefKind;
use crate::ts_type::TsTypeLiteralDef;
use crate::util::graph::resolve_deno_graph_module;
use crate::util::swc::get_location;
use crate::util::swc::get_text_info_location;
use crate::util::swc::js_doc_for_range;
use crate::util::swc::module_export_name_value;
use crate::util::swc::module_js_doc_for_source;
use crate::util::symbol::get_module_info;
use crate::variable::VariableDef;
use crate::visibility::SymbolVisibility;
use crate::DocNodeKind;
use crate::ImportDef;
use crate::Location;
use crate::ReexportKind;
use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::HashSet;
use std::error::Error;
use std::fmt;
use std::rc::Rc;

use deno_ast::swc::ast::ClassDecl;
use deno_ast::swc::ast::Decl;
@@ -38,7 +19,6 @@ use deno_ast::swc::ast::FnDecl;
use deno_ast::swc::ast::Ident;
use deno_ast::swc::ast::ImportSpecifier;
use deno_ast::swc::ast::ModuleDecl;
use deno_ast::swc::ast::ModuleItem;
use deno_ast::swc::ast::TsEnumDecl;
use deno_ast::swc::ast::TsInterfaceDecl;
use deno_ast::swc::ast::TsModuleDecl;
@@ -47,6 +27,7 @@ use deno_ast::swc::ast::TsTypeAliasDecl;
use deno_ast::swc::ast::VarDecl;
use deno_ast::swc::ast::VarDeclKind;
use deno_ast::swc::ast::VarDeclarator;
use deno_ast::ModuleItemRef;
use deno_ast::ParsedSource;
use deno_ast::SourceRange;
use deno_ast::SourceRanged;
@@ -58,18 +39,37 @@ use deno_graph::symbols::ModuleInfoRef;
use deno_graph::symbols::Symbol;
use deno_graph::symbols::SymbolNodeRef;
use deno_graph::symbols::UniqueSymbolId;
use deno_graph::EsParser;
use deno_graph::Module;
use deno_graph::ModuleGraph;
use deno_graph::ModuleParser;
use deno_graph::ModuleSpecifier;

use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::HashSet;
use std::error::Error;
use std::fmt;
use std::rc::Rc;
use crate::diagnostics::DiagnosticsCollector;
use crate::diagnostics::DocDiagnostic;
use crate::js_doc::JsDoc;
use crate::node;
use crate::node::DeclarationKind;
use crate::node::DocNode;
use crate::node::ModuleDoc;
use crate::node::NamespaceDef;
use crate::ts_type::infer_simple_ts_type_from_init;
use crate::ts_type::PropertyDef;
use crate::ts_type::TsTypeDef;
use crate::ts_type::TsTypeDefKind;
use crate::ts_type::TsTypeLiteralDef;
use crate::util::graph::resolve_deno_graph_module;
use crate::util::swc::get_location;
use crate::util::swc::get_text_info_location;
use crate::util::swc::js_doc_for_range;
use crate::util::swc::module_export_name_value;
use crate::util::swc::module_js_doc_for_source;
use crate::util::symbol::get_module_info;
use crate::variable::VariableDef;
use crate::visibility::SymbolVisibility;
use crate::DocNodeKind;
use crate::ImportDef;
use crate::Location;
use crate::ReexportKind;

#[derive(Debug)]
pub enum DocError {
@@ -132,7 +132,7 @@ pub struct DocParser<'a> {
impl<'a> DocParser<'a> {
pub fn new(
graph: &'a ModuleGraph,
parser: &'a dyn ModuleParser,
parser: &'a dyn EsParser,
options: DocParserOptions,
) -> Result<Self, anyhow::Error> {
let root_symbol =
@@ -317,11 +317,8 @@ impl<'a> DocParser<'a> {
let referrer = module_info.specifier();
let mut imports = vec![];

for node in &parsed_source.module().body {
if let deno_ast::swc::ast::ModuleItem::ModuleDecl(ModuleDecl::Import(
import_decl,
)) = node
{
for node in parsed_source.program_ref().body() {
if let ModuleItemRef::ModuleDecl(ModuleDecl::Import(import_decl)) = node {
if let Some(js_doc) =
js_doc_for_range(parsed_source, &import_decl.range())
{
@@ -781,14 +778,14 @@ impl<'a> DocParser<'a> {
}
}

fn get_imports_for_module_body(
fn get_imports_for_module_body<'item>(
&self,
module_body: &[ModuleItem],
module_body: impl Iterator<Item = ModuleItemRef<'item>>,
) -> HashMap<String, Import> {
let mut imports = HashMap::new();

for node in module_body.iter() {
if let ModuleItem::ModuleDecl(ModuleDecl::Import(import_decl)) = node {
for node in module_body {
if let ModuleItemRef::ModuleDecl(ModuleDecl::Import(import_decl)) = node {
for specifier in &import_decl.specifiers {
let import = match specifier {
ImportSpecifier::Named(named_specifier) => Import {
@@ -835,9 +832,9 @@ impl<'a> DocParser<'a> {
let Some(module_info) = module_info.esm() else {
return Vec::new();
};
let module_body = &module_info.source().module().body;
let program = module_info.source().program_ref();

let imports = self.get_imports_for_module_body(module_body);
let imports = self.get_imports_for_module_body(program.body());

let mut reexports: Vec<node::Reexport> = vec![];

@@ -853,8 +850,8 @@ impl<'a> DocParser<'a> {
}))
}

for node in module_body.iter() {
if let deno_ast::swc::ast::ModuleItem::ModuleDecl(module_decl) = node {
for node in program.body() {
if let ModuleItemRef::ModuleDecl(module_decl) = node {
let r = match module_decl {
ModuleDecl::ExportNamed(named_export) => {
if let Some(src) = &named_export.src {
@@ -1425,10 +1422,10 @@ fn parse_json_module_type(value: &serde_json::Value) -> TsTypeDef {
}

fn module_has_import(module_info: &EsModuleInfo) -> bool {
module_info.source().module().body.iter().any(|m| {
module_info.source().program_ref().body().any(|m| {
matches!(
m,
ModuleItem::ModuleDecl(
ModuleItemRef::ModuleDecl(
ModuleDecl::Import(_) | ModuleDecl::TsImportEquals(_)
)
)
5 changes: 2 additions & 3 deletions src/util/swc.rs
Original file line number Diff line number Diff line change
@@ -71,9 +71,8 @@ pub(crate) fn module_js_doc_for_source(
parsed_source: &ParsedSource,
) -> Option<Option<(JsDoc, SourceRange)>> {
let shebang_length = parsed_source
.module()
.shebang
.as_ref()
.program_ref()
.shebang()
.map_or(0, |shebang| shebang.len());
let pos_leading_comment =
parsed_source.comments().leading_map().keys().min()?;