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

chore: update deno_doc and deno_ast #823

Merged
merged 9 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 22 additions & 21 deletions Cargo.lock

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

21 changes: 17 additions & 4 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ deno_semver = "0.5.2"
flate2 = "1"
thiserror = "1"
async-tar = "0.4.2"
deno_graph = "0.83.3"
deno_ast = { version = "0.42.0", features = ["view"] }
deno_doc = { version = "0.155.0" }
comrak = { version = "0.28.0", default-features = false }
deno_graph = "0.84.1"
deno_ast = { version = "0.43.3", features = ["view"] }
deno_doc = { version = "0.157.0", features = ["comrak"] }
comrak = { version = "0.29.0", default-features = false }
async-trait = "0.1.73"
jsonwebkey = { version = "0.3.5", features = ["jsonwebtoken", "jwt-convert"] }
jsonwebtoken = "8.3.0"
Expand All @@ -96,6 +96,19 @@ sha1 = "0.10.6"
infer = "0.15.0"
x509-parser = { version = "0.15.1", features = ["verify"] }
sitemap-rs = "0.2.1"
html-escape = "0.2.13"

tree-sitter-highlight = "0.22.6"
tree-sitter-javascript = "0.21.4"
tree-sitter-typescript = "0.21.2"
tree-sitter-json = "0.21.0"
tree-sitter-regex = "0.21.0"
tree-sitter-css = "0.21.0"
tree-sitter-md = "0.2.3"
tree-sitter-rust = "0.21.2"
tree-sitter-html = "0.20.3"
tree-sitter-bash = "0.21.0"
tree-sitter-xml = "0.6.4"

[dev-dependencies]
flate2 = "1"
Expand Down
20 changes: 10 additions & 10 deletions api/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use deno_graph::source::NullFileSystem;
use deno_graph::BuildFastCheckTypeGraphOptions;
use deno_graph::BuildOptions;
use deno_graph::CapturingModuleAnalyzer;
use deno_graph::DefaultModuleParser;
use deno_graph::DefaultEsParser;
use deno_graph::GraphKind;
use deno_graph::ModuleGraph;
use deno_graph::ModuleInfo;
Expand Down Expand Up @@ -168,7 +168,7 @@ async fn analyze_package_inner(
fast_check_cache: None,
fast_check_dts: true,
jsr_url_provider: &PassthroughJsrUrlProvider,
module_parser: Some(&module_analyzer.analyzer),
es_parser: Some(&module_analyzer.analyzer),
resolver: Default::default(),
npm_resolver: Default::default(),
workspace_fast_check: WorkspaceFastCheckOption::Enabled(&workspace_members),
Expand Down Expand Up @@ -595,7 +595,7 @@ async fn rebuild_npm_tarball_inner(
fast_check_cache: Default::default(),
fast_check_dts: true,
jsr_url_provider: &PassthroughJsrUrlProvider,
module_parser: Some(&module_analyzer.analyzer),
es_parser: Some(&module_analyzer.analyzer),
resolver: None,
npm_resolver: None,
workspace_fast_check: WorkspaceFastCheckOption::Enabled(&workspace_members),
Expand Down Expand Up @@ -680,14 +680,14 @@ impl<'a> deno_graph::source::Loader for GcsLoader<'a> {
}

#[derive(Default)]
pub struct ModuleParser(DefaultModuleParser);
pub struct ModuleParser(DefaultEsParser);

impl deno_graph::ModuleParser for ModuleParser {
fn parse_module(
impl deno_graph::EsParser for ModuleParser {
fn parse_program(
&self,
options: deno_graph::ParseOptions,
) -> Result<ParsedSource, deno_ast::ParseDiagnostic> {
let source = self.0.parse_module(options)?;
let source = self.0.parse_program(options)?;
if let Some(err) = source.diagnostics().first() {
return Err(err.clone());
}
Expand Down Expand Up @@ -817,9 +817,9 @@ fn check_for_banned_syntax(
(line_number, column_number)
};

for i in parsed_source.module().body.iter() {
for i in parsed_source.program_ref().body() {
match i {
ast::ModuleItem::ModuleDecl(n) => match n {
deno_ast::ModuleItemRef::ModuleDecl(n) => match n {
ast::ModuleDecl::TsNamespaceExport(n) => {
let (line, column) = line_col(&n.range());
return Err(PublishError::GlobalTypeAugmentation {
Expand Down Expand Up @@ -894,7 +894,7 @@ fn check_for_banned_syntax(
}
_ => continue,
},
ast::ModuleItem::Stmt(n) => match n {
deno_ast::ModuleItemRef::Stmt(n) => match n {
ast::Stmt::Decl(ast::Decl::TsModule(n)) => {
if n.global {
let (line, column) = line_col(&n.range());
Expand Down
9 changes: 8 additions & 1 deletion api/src/api/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ pub async fn get_docs_handler(
match docs {
GeneratedDocsOutput::Docs(docs) => Ok(ApiPackageVersionDocs::Content {
css: Cow::Borrowed(deno_doc::html::STYLESHEET),
comrak_css: Cow::Borrowed(deno_doc::html::comrak::COMRAK_STYLESHEET),
script: Cow::Borrowed(deno_doc::html::SCRIPT_JS),
breadcrumbs: docs.breadcrumbs,
toc: docs.toc,
Expand Down Expand Up @@ -1300,7 +1301,9 @@ pub async fn get_source_handler(
let source = if let Some(file) = file {
let size = file.len();

let highlighter = deno_doc::html::setup_highlighter(true);
let highlighter = crate::tree_sitter::ComrakAdapter {
show_line_numbers: true,
};

let view = if let Ok(file) = String::from_utf8(file.to_vec()) {
let mut out = vec![];
Expand Down Expand Up @@ -2644,6 +2647,7 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
ApiPackageVersionDocs::Content {
version,
css,
comrak_css: _,
script: _,
breadcrumbs,
toc,
Expand All @@ -2669,6 +2673,7 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
ApiPackageVersionDocs::Content {
version,
css,
comrak_css: _,
script: _,
breadcrumbs,
toc,
Expand Down Expand Up @@ -2698,6 +2703,7 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
ApiPackageVersionDocs::Content {
version,
css,
comrak_css: _,
script: _,
breadcrumbs,
toc,
Expand Down Expand Up @@ -2730,6 +2736,7 @@ ggHohNAjhbzDaY2iBW/m3NC5dehGUP4T2GBo/cwGhg==
ApiPackageVersionDocs::Content {
version,
css,
comrak_css: _,
script: _,
breadcrumbs,
toc,
Expand Down
2 changes: 2 additions & 0 deletions api/src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,11 @@ pub struct ApiPackageVersion {
#[serde(rename_all = "camelCase", tag = "kind")]
#[allow(clippy::large_enum_variant)]
pub enum ApiPackageVersionDocs {
#[serde(rename_all = "camelCase")]
Content {
version: ApiPackageVersion,
css: Cow<'static, str>,
comrak_css: Cow<'static, str>,
script: Cow<'static, str>,
breadcrumbs: Option<String>,
toc: Option<String>,
Expand Down
Loading
Loading