From bf081ec34790c5fb57dfd076fd57425e7678efdc Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Wed, 13 Aug 2025 12:12:08 +0800 Subject: [PATCH] feat: export package docs to json format and render to html (#1809) It provides a `package-doc.json` and HTML is rendered using a `package-doc` function. ```typ #let package-doc(info, path: none) [ #metadata(( // more sub paths )) #render-page(info, path) // the content of $path/.html ] #package-doc(json("package-doc.json")) ``` --- crates/tinymist-query/src/docs/module.rs | 11 +- .../tinymist-query/src/docs/package-doc.typ | 299 ++++ crates/tinymist-query/src/docs/package.rs | 364 +++-- crates/tinymist/src/cmd.rs | 5 +- typ/packages/package-docs/global.css | 323 ++++ typ/packages/package-docs/main.typ | 0 typ/packages/package-docs/template.typ | 278 ++++ typ/packages/package-docs/theme-style.toml | 30 + typ/packages/package-docs/theme.typ | 55 + typ/packages/package-docs/tokyo-night.tmTheme | 1308 +++++++++++++++++ typ/packages/package-docs/typst.toml | 4 + 11 files changed, 2544 insertions(+), 133 deletions(-) create mode 100644 crates/tinymist-query/src/docs/package-doc.typ create mode 100644 typ/packages/package-docs/global.css create mode 100644 typ/packages/package-docs/main.typ create mode 100644 typ/packages/package-docs/template.typ create mode 100644 typ/packages/package-docs/theme-style.toml create mode 100644 typ/packages/package-docs/theme.typ create mode 100644 typ/packages/package-docs/tokyo-night.tmTheme create mode 100644 typ/packages/package-docs/typst.toml diff --git a/crates/tinymist-query/src/docs/module.rs b/crates/tinymist-query/src/docs/module.rs index 78934843..aad8580e 100644 --- a/crates/tinymist-query/src/docs/module.rs +++ b/crates/tinymist-query/src/docs/module.rs @@ -66,6 +66,8 @@ pub fn module_docs(ctx: &mut LocalContext, entry_point: FileId) -> StrResult, /// Whether the definition external to the module. pub is_external: bool, + /// The module link to the definition + pub module_link: Option, + /// The symbol link to the definition + pub symbol_link: Option, /// The link to the definition if it is external. pub external_link: Option, /// The one-line documentation of the definition. @@ -90,7 +96,7 @@ pub struct DefInfo { #[serde(skip)] pub decl: Option>, /// The children of the definition. - pub children: EcoVec, + pub children: Vec, } /// Information about the definitions in a package. @@ -206,6 +212,7 @@ impl ScanDefCtx<'_> { }; let mut head = DefInfo { + id: EcoString::new(), name: key.to_string().into(), kind: decl.kind(), constant: expr.map(|expr| expr.repr()), @@ -215,6 +222,8 @@ impl ScanDefCtx<'_> { children: children.unwrap_or_default(), loc: None, is_external: false, + module_link: None, + symbol_link: None, external_link: None, oneliner: None, }; diff --git a/crates/tinymist-query/src/docs/package-doc.typ b/crates/tinymist-query/src/docs/package-doc.typ new file mode 100644 index 00000000..42285055 --- /dev/null +++ b/crates/tinymist-query/src/docs/package-doc.typ @@ -0,0 +1,299 @@ +#import "@preview/cmarker:0.1.6": render +// re-export page template +#import "/typ/packages/package-docs/template.typ": project + +#let module-divider = html.elem("hr", attrs: (class: "module-divider")); +#show link: it => if type(it.dest) == label { + html.elem("a", attrs: (href: "#" + str(it.dest), class: "symbol-link"), it.body) +} else { + it +} +#let heading-label(name) = { + let it = name.replace(regex("[\s\:]"), "-").replace(regex("[.()]"), "").replace(regex("-+"), "-").replace("M", "m") + label(it) +} +#let labelled-heading(depth, it) = { + heading(depth: depth, html.elem("span", attrs: (id: str(heading-label(it))), it)) +} +#let markdown-docs = render.with( + scope: ( + image: (src, alt: none) => { + html.elem("img", attrs: (src: src, alt: alt, class: "code-image")) + }, + ), +) + +#let display-package-spec(pkg-spec) = { + "@" + pkg-spec.meta.namespace + "/" + pkg-spec.meta.name + ":" + pkg-spec.meta.version +} + +#let span = html.elem.with("span") +#let code = html.elem.with("code") +#let keyword = code.with(attrs: (class: "code-kw")) +#let builtin-ty = code.with(attrs: (class: "type-builtin")) + +#let symbol-doc(symbol-ctx, info) = { + // let ident = if !primary.is_empty() { + // eco_format!("symbol-{}-{primary}.{}", child.kind, child.name) + // } else { + // eco_format!("symbol-{}-{}", child.kind, child.name) + // }; + + let symlink(body) = if info.symbol_link != none { + // let _ = writeln!(out, "#link({})[Symbol Docs]\n", TypstLink(lnk)); + html.elem("a", attrs: (href: info.symbol_link, class: "symbol-link"), body) + } else { + body + } + + if info.is_external { + let fid = info.loc.at(0, default: none) + let file = symbol-ctx.files.at(fid, default: none) + let package = symbol-ctx.packages.at(file.package, default: none) + + let title = if info.kind == "module" { + let title = if package != none and file.package > 0 { + span(attrs: (title: display-package-spec(package)), "external") + code(" ") + code(file.path) + } else { + code(file.path) + } + + symlink(code(title)) + } else { + // keyword("extern") + // code(" ") + symlink(code(info.name)) + if info.kind == "function" { + code("()") + } else { + code(": ") + builtin-ty[any] + } + } + + html.elem("div", attrs: (class: "detail-header doc-symbol-" + info.kind), [=== #title]) + + if info.oneliner != none { + markdown-docs(info.oneliner) + } + + return + } + + labelled-heading(3, info.kind + ": " + info.name + " in " + symbol-ctx.in-module) + + // if info.symbol_link != none { + // // let _ = writeln!(out, "#link({})[Symbol Docs]\n", TypstLink(lnk)); + // par(symlink("Symbol Docs")) + // } + + // let convert_err = None::; + if info.parsed_docs != none { + if info.parsed_docs.kind == "func" { + // if let Some(DefDocs::Function(sig)) = &info.parsed_docs { + // // let _ = writeln!(out, ""); + // let _ = writeln!(out, "```typc"); + // let _ = write!(out, "let {}", info.name); + // let _ = sig.print(&mut out); + // let _ = writeln!(out, ";"); + // let _ = writeln!(out, "```"); + // // let _ = writeln!(out, ""); + // } + // repr(info.parsed_docs) + } + } + + let printed_docs = false + if not info.is_external { + // let convert_err = None::; + if info.parsed_docs != none { + let docs = info.parsed_docs + if docs.docs != none and docs.docs.len() > 0 { + // remove_list_annotations(docs.docs()) + printed_docs = true + markdown-docs(docs.docs) + } + if docs.kind == "func" { + labelled-heading(4, "Resultant") + + docs.ret_ty.at(0) + + labelled-heading(4, "Parameters") + + let pos = docs.at("pos", default: ()) + let named = docs.at("named", default: (:)).values() + let rest = docs.at("rest", default: none) + + let params = pos + named + if rest != none { + params.push(rest) + } + + for param in params { + labelled-heading(5, param.name) + + let param-head = (param.name, ": ", param.cano_type.at(0)) + if param.positional { + param-head.push(" (Positional)") + } + if param.variadic { + param-head.push(" (Variadic)") + } + if param.settable { + param-head.push(" (Settable)") + } + if param.named { + param-head.push(" (Named, default: ") + param-head.push(param.default) + param-head.push(")") + } + raw(block: true, param-head.join()) + + markdown-docs(param.docs) + } + } + } + } + + if not printed_docs { + let plain_docs = info.docs + if plain_docs == none { + plain_docs = info.oneliner + } + // todo: eval with error tolerance? + // if plain_docs != none { + // eval(plain_docs, mode: "markup") + // } + + // if let Some(lnk) = &child.module_link { + // match lnk.as_str() { + // "builtin" => { + // let _ = writeln!(out, "A Builtin Module"); + // } + // _lnk => { + // // let _ = writeln!(out, "#link({})[Module Docs]\n", + // // TypstLink(lnk)); + // } + // } + // } + + // // let _ = writeln!(out, ""); + // let _ = writeln!(out, "]),"); + } +} + +#let analyze-package(p) = { + ( + packages: p.packages, + files: p.files, + ) +} + +#let analyze-module(m) = { + let modules = () + let functions = () + let constants = () + let unknowns = () + + for child in m.children { + if child.kind == "module" { + modules.push(child) + } else if child.kind == "function" { + functions.push(child) + } else if child.kind == "variable" { + constants.push(child) + } else { + unknowns.push(child) + } + } + + ( + modules: modules.sorted(key: it => it.id), + functions: functions, + constants: constants, + unknowns: unknowns, + ) +} + +#let module-doc(info: none, name: none, symbol-ctx, m) = { + let m = analyze-module(m) + + if info.prefix.len() > 0 { + let primary = info.prefix + let title = "Module: " + primary + " in " + info.prefix + + module-divider + labelled-heading(1, title) + } else { + labelled-heading(1, "Package Exports") + } + + let symbol-ctx = ( + in-module: info.prefix, + ..symbol-ctx, + ) + + if m.modules.len() > 0 { + [== Modules] + for child in m.modules { + symbol-doc(symbol-ctx, child) + } + } + if m.constants.len() > 0 { + [== Constants] + for child in m.constants { + symbol-doc(symbol-ctx, child) + } + } + if m.functions.len() > 0 { + [== Functions] + for child in m.functions { + symbol-doc(symbol-ctx, child) + } + } + if m.unknowns.len() > 0 { + [== Unknowns] + for child in m.unknowns { + symbol-doc(symbol-ctx, child) + } + } +} +#let package-doc(info) = { + let info = json(info) + let title = "@" + info.meta.namespace + "/" + info.meta.name + " " + info.meta.version + + show: project.with(title: title) + html.elem("style", read("/typ/packages/package-docs/global.css")) + show: html.elem.with("main") + + strong[ + This documentation is generated locally. Please submit issues to #link("https://github.com/Myriad-Dreamin/tinymist")[tinymist] if you see incorrect information in it. + ] + + html.elem("h1", attrs: (id: "package-doc-title"), title) + + let repo = info.meta.manifest.package.at("repository", default: none) + if repo != none { + let repo_link = html.elem("a", attrs: (href: repo, class: "package-repo-link"), "Repository") + html.elem("p", repo_link) + } + + let description = info.meta.manifest.package.at("description", default: none) + if description != none { + description + } + + let symbol-ctx = analyze-package(info) + + + for (name, m, info) in info.modules { + module-doc(info: info, name: name, symbol-ctx, m) + } +} diff --git a/crates/tinymist-query/src/docs/package.rs b/crates/tinymist-query/src/docs/package.rs index d5b710fb..26446a31 100644 --- a/crates/tinymist-query/src/docs/package.rs +++ b/crates/tinymist-query/src/docs/package.rs @@ -5,6 +5,8 @@ use std::path::PathBuf; use ecow::{EcoString, EcoVec}; use indexmap::IndexSet; use serde::{Deserialize, Serialize}; +use tinymist_analysis::docs::tidy::remove_list_annotations; +use tinymist_world::package::PackageSpec; use typst::diag::{eco_format, StrResult}; use typst::syntax::package::PackageManifest; use typst::syntax::{FileId, Span}; @@ -13,13 +15,29 @@ use crate::docs::{file_id_repr, module_docs, DefDocs, PackageDefInfo}; use crate::package::{get_manifest_id, PackageInfo}; use crate::LocalContext; -use tinymist_analysis::docs::tidy::remove_list_annotations; +/// Documentation Information about a package. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PackageDoc { + meta: PackageMeta, + packages: Vec, + files: Vec, + modules: Vec<(EcoString, crate::docs::DefInfo, ModuleInfo)>, +} + +/// Documentation Information about a package module. +#[derive(Debug, Clone, Serialize, Deserialize)] +struct ModuleInfo { + prefix: EcoString, + name: EcoString, + loc: Option, + parent_ident: EcoString, + aka: EcoVec, +} /// Generate full documents in markdown format -pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult { +pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult { log::info!("generate_md_docs {spec:?}"); - let mut md = String::new(); let toml_id = get_manifest_id(spec)?; let manifest = ctx.get_manifest(toml_id)?; @@ -32,16 +50,6 @@ pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult StrResult"); let mut modules_to_generate = vec![(root.name.clone(), root)]; let mut generated_modules = HashSet::new(); @@ -72,10 +78,11 @@ pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult StrResult, - parent_ident: EcoString, - aka: EcoVec, - } - let module_info = jbase64(&ModuleInfo { + let module_info = ModuleInfo { prefix: primary.as_str().into(), name: def.name.clone(), loc: persist_fid, parent_ident: parent_ident.clone(), aka, - }); - let _ = writeln!(md, ""); + }; - for mut child in children { + for child in def.children.iter_mut() { let span = child.decl.as_ref().map(|decl| decl.span()); let fid_range = span.and_then(|v| { v.id().and_then(|fid| { @@ -127,9 +120,7 @@ pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult; - if let Some(docs) = &child.parsed_docs { - child.parsed_docs = Some(docs.clone()); + if child.parsed_docs.is_some() { child.docs = None; } @@ -138,7 +129,6 @@ pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult StrResult"); - - if let Some(DefDocs::Function(sig)) = &child.parsed_docs { - let _ = writeln!(md, ""); - let _ = writeln!(md, "```typc"); - let _ = write!(md, "let {}", child.name); - let _ = sig.print(&mut md); - let _ = writeln!(md, ";"); - let _ = writeln!(md, "```"); - let _ = writeln!(md, ""); - } - - let mut printed_docs = false; - match (&child.parsed_docs, convert_err) { - (_, Some(err)) => { - let err = format!("failed to convert docs in {title}: {err}").replace( - "-->", "—>", // avoid markdown comment - ); - let _ = writeln!(md, ""); - errors.push(err); - } - (Some(docs), _) if !child.is_external => { - let _ = writeln!(md, "{}", remove_list_annotations(docs.docs())); - printed_docs = true; - if let DefDocs::Function(docs) = docs { - for param in docs - .pos - .iter() - .chain(docs.named.values()) - .chain(docs.rest.as_ref()) - { - let _ = writeln!(md, "", param.name); - let ty = match ¶m.cano_type { - Some((short, _, _)) => short, - None => "unknown", - }; - let _ = writeln!( - md, - "#### {} ({ty:?})\n\n{}\n", - param.name, param.name, param.docs, param.name - ); - let _ = writeln!(md, ""); - } - } - } - (_, None) => {} - } - - if !printed_docs { - let plain_docs = child.docs.as_deref(); - let plain_docs = plain_docs.or(child.oneliner.as_deref()); - - if let Some(docs) = plain_docs { - let contains_code = docs.contains("```"); - if contains_code { - let _ = writeln!(md, "`````typ"); - } - let _ = writeln!(md, "{docs}"); - if contains_code { - let _ = writeln!(md, "`````"); - } - } - } - if !child_children.is_empty() { crate::log_debug_ct!("sub_fid: {child_fid:?}"); - match child_fid { + let lnk = match child_fid { Some(fid) => { let aka = akas(fid); let primary = aka.first().cloned().unwrap_or_default(); - let link = format!("module-{primary}").replace(".", ""); - let _ = writeln!(md, "[Module Docs](#{link})\n"); if generated_modules.insert(fid) { + let mut child = child.clone(); child.children = child_children; modules_to_generate.push((ident.clone(), child)); } + + let link = format!("module-{primary}").replace(".", ""); + format!("#{link}") } - None => { - let _ = writeln!(md, "A Builtin Module"); - } - } + None => "builtin".to_owned(), + }; + + child.module_link = Some(lnk); } - let _ = writeln!(md, ""); + child.id = ident; } - let _ = writeln!(md, ""); + modules.push((parent_ident, def, module_info)); } } - let res = ConvertResult { errors }; - let err = jbase64(&res); - let _ = writeln!(md, ""); - let _ = writeln!(md, "## Errors"); - for errs in res.errors { - let _ = writeln!(md, "- {errs}"); - } - let _ = writeln!(md, ""); - let mut packages = IndexSet::new(); let files = file_ids @@ -295,11 +213,172 @@ pub fn package_docs(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult"); + let doc = PackageDoc { + meta, + packages, + files, + modules, + }; - Ok(md) + Ok(doc) +} + +/// Generate full documents in markdown format +pub fn package_docs_typ(doc: &PackageDoc) -> StrResult { + let mut out = String::new(); + + let _ = writeln!(out, "{}", include_str!("package-doc.typ")); + + let pi = &doc.meta; + let _ = writeln!( + out, + "#package-doc(bytes(read(\"{}-{}-{}.json\")))", + pi.namespace, pi.name, pi.version, + ); + + Ok(out) +} + +/// Generate full documents in markdown format +pub fn package_docs_md(doc: &PackageDoc) -> StrResult { + let mut out = String::new(); + + let title = doc.meta.spec().to_string(); + + writeln!(out, "# {title}").unwrap(); + out.push('\n'); + writeln!(out, "This documentation is generated locally. Please submit issues to [tinymist](https://github.com/Myriad-Dreamin/tinymist/issues) if you see **incorrect** information in it.").unwrap(); + out.push('\n'); + out.push('\n'); + + let package_meta = jbase64(&doc.meta); + let _ = writeln!(out, ""); + + let mut errors = vec![]; + for (parent_ident, def, module_info) in &doc.modules { + // parent_ident, symbols + let primary = &module_info.prefix; + if !module_info.prefix.is_empty() { + let _ = writeln!(out, "---\n## Module: {primary}"); + } + + crate::log_debug_ct!("module: {primary} -- {parent_ident}"); + let module_info = jbase64(&module_info); + let _ = writeln!(out, ""); + + for child in &def.children { + let convert_err = None::; + + let ident = if !primary.is_empty() { + eco_format!("symbol-{}-{primary}.{}", child.kind, child.name) + } else { + eco_format!("symbol-{}-{}", child.kind, child.name) + }; + let _ = writeln!(out, "### {}: {} in {primary}", child.kind, child.name); + + if let Some(lnk) = &child.symbol_link { + let _ = writeln!(out, "[Symbol Docs]({lnk})\n"); + } + + let head = jbase64(&child); + let _ = writeln!(out, ""); + + if let Some(DefDocs::Function(sig)) = &child.parsed_docs { + let _ = writeln!(out, ""); + let _ = writeln!(out, "```typc"); + let _ = write!(out, "let {}", child.name); + let _ = sig.print(&mut out); + let _ = writeln!(out, ";"); + let _ = writeln!(out, "```"); + let _ = writeln!(out, ""); + } + + let mut printed_docs = false; + match (&child.parsed_docs, convert_err) { + (_, Some(err)) => { + let err = format!("failed to convert docs in {title}: {err}").replace( + "-->", "—>", // avoid markdown comment + ); + let _ = writeln!(out, ""); + errors.push(err); + } + (Some(docs), _) if !child.is_external => { + let _ = writeln!(out, "{}", remove_list_annotations(docs.docs())); + printed_docs = true; + if let DefDocs::Function(docs) = docs { + for param in docs + .pos + .iter() + .chain(docs.named.values()) + .chain(docs.rest.as_ref()) + { + let _ = writeln!(out, "", param.name); + let ty = match ¶m.cano_type { + Some((short, _, _)) => short, + None => "unknown", + }; + let _ = writeln!( + out, + "#### {} ({ty:?})\n\n{}\n", + param.name, param.name, param.docs, param.name + ); + let _ = writeln!(out, ""); + } + } + } + (_, None) => {} + } + + if !printed_docs { + let plain_docs = child.docs.as_deref(); + let plain_docs = plain_docs.or(child.oneliner.as_deref()); + + if let Some(docs) = plain_docs { + let contains_code = docs.contains("```"); + if contains_code { + let _ = writeln!(out, "`````typ"); + } + let _ = writeln!(out, "{docs}"); + if contains_code { + let _ = writeln!(out, "`````"); + } + } + } + + if let Some(lnk) = &child.module_link { + match lnk.as_str() { + "builtin" => { + let _ = writeln!(out, "A Builtin Module"); + } + lnk => { + let _ = writeln!(out, "[Module Docs]({lnk})\n"); + } + } + } + + let _ = writeln!(out, ""); + } + + let _ = writeln!(out, ""); + } + + let res = ConvertResult { errors }; + let err = jbase64(&res); + let _ = writeln!(out, ""); + let _ = writeln!(out, "## Errors"); + for errs in res.errors { + let _ = writeln!(out, "- {errs}"); + } + let _ = writeln!(out, ""); + + let meta = PackageMetaEnd { + packages: doc.packages.clone(), + files: doc.files.clone(), + }; + let package_meta = jbase64(&meta); + let _ = writeln!(out, ""); + + Ok(out) } fn jbase64(s: &T) -> String { @@ -309,7 +388,7 @@ fn jbase64(s: &T) -> String { } /// Information about a package. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct PackageMeta { /// The namespace the package lives in. pub namespace: EcoString, @@ -321,6 +400,17 @@ pub struct PackageMeta { pub manifest: Option, } +impl PackageMeta { + /// Returns the package's full name, including namespace and version. + pub fn spec(&self) -> PackageSpec { + PackageSpec { + namespace: self.namespace.clone(), + name: self.name.clone(), + version: self.version.parse().expect("Invalid version format"), + } + } +} + /// Information about a package. #[derive(Debug, Serialize, Deserialize)] pub struct PackageMetaEnd { @@ -329,7 +419,7 @@ pub struct PackageMetaEnd { } /// Information about a package. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct FileMeta { package: Option, path: PathBuf, @@ -344,7 +434,7 @@ struct ConvertResult { mod tests { use tinymist_world::package::{PackageRegistry, PackageSpec}; - use super::{package_docs, PackageInfo}; + use super::{package_docs, package_docs_md, package_docs_typ, PackageInfo}; use crate::tests::*; fn test(pkg: PackageSpec) { @@ -358,11 +448,23 @@ mod tests { }; run_with_ctx(verse, path, &|a, _p| { let docs = package_docs(a, &pi).unwrap(); + let dest = format!( + "../../target/{}-{}-{}.json", + pi.namespace, pi.name, pi.version + ); + std::fs::write(dest, serde_json::to_string_pretty(&docs).unwrap()).unwrap(); + let typ = package_docs_typ(&docs).unwrap(); + let dest = format!( + "../../target/{}-{}-{}.typ", + pi.namespace, pi.name, pi.version + ); + std::fs::write(dest, typ).unwrap(); + let md = package_docs_md(&docs).unwrap(); let dest = format!( "../../target/{}-{}-{}.md", pi.namespace, pi.name, pi.version ); - std::fs::write(dest, docs).unwrap(); + std::fs::write(dest, md).unwrap(); }) }) } @@ -381,7 +483,7 @@ mod tests { test(PackageSpec { namespace: "preview".into(), name: "touying".into(), - version: "0.5.2".parse().unwrap(), + version: "0.6.0".parse().unwrap(), }); } diff --git a/crates/tinymist/src/cmd.rs b/crates/tinymist/src/cmd.rs index a2eeccb3..7e607a5c 100644 --- a/crates/tinymist/src/cmd.rs +++ b/crates/tinymist/src/cmd.rs @@ -735,7 +735,10 @@ impl ServerState { info: PackageInfo, ) -> LspResult>> { self.within_package(info.clone(), move |a| { - tinymist_query::docs::package_docs(a, &info) + let doc = tinymist_query::docs::package_docs(a, &info) + .map_err(map_string_err("failed to generate docs")) + .map_err(internal_error)?; + tinymist_query::docs::package_docs_md(&doc) .map_err(map_string_err("failed to generate docs")) .map_err(internal_error) }) diff --git a/typ/packages/package-docs/global.css b/typ/packages/package-docs/global.css new file mode 100644 index 00000000..8fb68103 --- /dev/null +++ b/typ/packages/package-docs/global.css @@ -0,0 +1,323 @@ +@import url("https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,700;0,900;1,300;1,700&display=swap"); + +main { + margin: 2em; +} +:root.light { + --main-color: #000; + --main-hover-color: #222939; + --raw-bg-color: rgba(101, 117, 133, 0.16); + --main-bg-color: #fafcfc; + --nav-bg-color: #fafcfc; + --gray-color: #6d6d6d; + --accent: oklch(51.51% 0.2307 257.85); + --accent-dark: oklch(64.94% 0.1982 251.813); + --black: #0f1219; +} + +:root { + --mainLight: hsl(250, 68%, 74%); + --textDetailAccent: var(--mainLight); + --main-color: #dfdfd6; + --main-hover-color: #fff; + --gray-color: #939da3; + --raw-bg-color: #65758529; + --main-bg-color: #212737; + --nav-bg-color: #212737; + --accent: oklch(71.7% 0.1648 250.794); + --accent-dark: oklch(51.51% 0.2307 257.85); + --vp-font-family-mono: ui-monospace, "Menlo", "Monaco", "Consolas", "Liberation Mono", + "Courier New", monospace; + --vp-font-family-base: + Merriweather, + serif, + "Inter var experimental", + "Inter var", + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Roboto, + Oxygen, + Ubuntu, + Cantarell, + "Fira Sans", + "Droid Sans", + "Helvetica Neue", + sans-serif; +} +body { + margin: 0; + padding: 0; + text-align: justify; + font-family: var(--vp-font-family-base); + background: var(--main-bg-color); + background-size: 100% 600px; + word-wrap: break-word; + overflow-wrap: break-word; + color: var(--main-color); + line-height: 1.7; +} + +h1 :target, +h2 :target, +h3 :target, +h4 :target, +h5 :target, +h6 :target { + scroll-margin-top: 1.25em; +} +h1 { + font-size: 2.75em; + margin-block-start: 0em; + margin-block-end: 0.8888889em; + margin-inline-start: 0px; + margin-inline-end: 0px; + line-height: 1.1111111; +} +h2 { + font-size: 2em; + margin-block-start: 1.6em; + margin-block-end: 0.6em; + margin-inline-start: 0px; + margin-inline-end: 0px; + line-height: 1.3333333; +} +h3 { + font-size: 1.5em; + margin-block-start: 1.5em; + margin-block-end: 0.6em; + margin-inline-start: 0px; + margin-inline-end: 0px; + line-height: 1.45; +} +h4 { + font-size: 1.25em; + margin-block-start: 1.5em; + margin-block-end: 0.6em; + margin-inline-start: 0px; + margin-inline-end: 0px; + line-height: 1.6; +} +h5 { + font-size: 1.1em; + margin-block-start: 1.5em; + margin-block-end: 0.5em; + margin-inline-start: 0px; + margin-inline-end: 0px; + line-height: 1.5; +} +p { + margin-block-end: 0.5em; +} +strong, +b { + font-weight: 700; +} +a, +.link { + color: var(--accent); + text-decoration: underline; + cursor: pointer; +} +a, +.link { + transition: + color 0.1s, + underline 0.1s; +} +a:hover, +.link:hover { + color: var(--accent-dark); + text-decoration: underline solid 2px; +} +textarea { + width: 100%; + font-size: 16px; +} +input { + font-size: 16px; +} +table { + width: 100%; +} +img { + max-width: 100%; + height: auto; + border-radius: 8px; +} +pre, +code, +kbd, +samp { + font-family: var(--vp-font-family-mono); +} +code { + padding: 2px 5px; + background-color: var(--raw-bg-color); + border-radius: 2px; +} +pre { + padding: 1.5em; + border-radius: 8px; +} +pre > code { + all: unset; +} +blockquote { + border-left: 4px solid var(--accent); + padding: 0 0 0 18px; + margin: 0px; + font-size: 1.333em; +} +hr { + border: none; + border-top: 1px solid var(--raw-bg-color); +} + +.sr-only { + border: 0; + padding: 0; + margin: 0; + position: absolute !important; + height: 1px; + width: 1px; + overflow: hidden; + /* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */ + clip: rect(1px 1px 1px 1px); + /* maybe deprecated but we need to support legacy browsers */ + clip: rect(1px, 1px, 1px, 1px); + /* modern browsers, clip-path works inwards from each corner */ + clip-path: inset(50%); + /* added line to stop words getting smushed together (as they go onto separate lines and some screen readers do not understand line feeds as a space */ + white-space: nowrap; +} +nav a, +.social-links a { + text-decoration: none; + color: var(--main-color); +} +nav a:hover, +.social-links a:hover { + color: var(--main-hover-color); +} +.icon svg { + width: 32px; + height: 32px; + overflow: visible; +} +.icon svg path, +.icon svg circle { + fill: currentColor; +} +.theme-icon { + cursor: pointer; +} +.dark .theme-icon.light { + display: none; +} +.dark .theme-icon.dark { + display: dark; +} +.theme-icon.light { + display: dark; +} +.theme-icon.dark { + display: none; +} +.dark .code-image.themed .light { + display: none; +} +.dark .code-image.themed .dark { + display: initial; +} +.code-image.themed .light { + display: initial; +} +.code-image.themed .dark { + display: none; +} + +figcaption { + text-align: center; +} +.code-image svg { + max-width: 100%; + height: fit-content; +} +.inline-equation { + display: inline-block; + width: fit-content; + margin: 0 0.15em; +} +.block-equation { + display: grid; + place-items: center; + overflow-x: auto; +} + +.detail-header { + margin: 1em 0; + margin-top: 1.5em; + padding: 0.5em 1em; + background-color: rgba(255, 255, 255, 0.05); + border-left: 3px solid var(--textDetailAccent); + font-size: 1em; + position: relative; +} + +.detail-header h4 { + font-size: 1em; + font-weight: 700; + margin: 0; +} + +.detail-header code { + background-color: transparent; + margin: 0; + padding: 0; +} + +.detail-header span > p { + display: inline-block; + margin: 0; + padding: 0; +} + +.type-int { + color: #e7d9ff; +} + +.type-float { + color: #e7d9ff; +} + +.type-builtin { + color: #d2a8ff; +} + +.type-none { + color: #ff6d00; +} + +.code-kw, +.type-auto { + color: #ff6d00; +} + +.code-func { + color: #79c0ff; +} + +.code-op { + color: #79c0ff; +} + +.type-inferred-as, +.code-kw.type-inferred { + transition: background-color 0.1s; +} + +.type-inferred-as:hover, +.code-kw.type-inferred:hover { + background-color: #344134; +} diff --git a/typ/packages/package-docs/main.typ b/typ/packages/package-docs/main.typ new file mode 100644 index 00000000..e69de29b diff --git a/typ/packages/package-docs/template.typ b/typ/packages/package-docs/template.typ new file mode 100644 index 00000000..f6169c75 --- /dev/null +++ b/typ/packages/package-docs/template.typ @@ -0,0 +1,278 @@ +// This is important for shiroa to produce a responsive layout +// and multiple targets. +#import "@preview/shiroa:0.2.2": ( + get-page-width, is-html-target, is-pdf-target, is-web-target, plain-text, shiroa-sys-target, target, templates, +) +#import templates: * +#import "@preview/numbly:0.1.0": numbly +#import "@preview/zebraw:0.5.2": zebraw, zebraw-init +#import "theme.typ": * + +// Metadata +#let page-width = get-page-width() +#let is-html-target = is-html-target() +#let is-pdf-target = is-pdf-target() +#let is-web-target = is-web-target() +#let is-md-target = target == "md" +#let sys-is-html-target = ("target" in dictionary(std)) + +#let part-counter = counter("shiroa-part-counter") +/// Creates an embedded block typst frame. +#let div-frame(content, attrs: (:)) = html.elem("div", html.frame(content), attrs: attrs) +#let span-frame(content, attrs: (:)) = html.elem("span", html.frame(content), attrs: attrs) + +// Theme (Colors) +#let ( + style: theme-style, + is-dark: is-dark-theme, + is-light: is-light-theme, + main-color: main-color, + dash-color: dash-color, + code-extra-colors: code-extra-colors, +) = book-theme-from(toml("theme-style.toml"), xml: it => xml(it)) +#let gh-dark-fg = rgb("#f0f6fc") + +// Fonts +#let main-font = ( + "Charter", + "Libertinus Serif", + "Source Han Serif SC", + // shiroa's embedded font +) +#let code-font = ( + "BlexMono Nerd Font Mono", + // shiroa's embedded font + "DejaVu Sans Mono", +) + +// Sizes +#let main-size = if is-web-target { + 16pt +} else { + 10.5pt +} +// , +#let heading-sizes = (22pt, 18pt, 14pt, 12pt, main-size, main-size, main-size) +#let list-indent = 0.5em + +#let raw-rules(body) = { + let init-with-theme((code-extra-colors, is-dark)) = if is-dark { + zebraw-init.with( + // should vary by theme + background-color: if code-extra-colors.bg != none { + (code-extra-colors.bg, code-extra-colors.bg) + }, + highlight-color: rgb("#3d59a1"), + comment-color: rgb("#394b70"), + lang-color: rgb("#3d59a1"), + lang: false, + numbering: false, + ) + } else { + zebraw-init.with( + // should vary by theme + background-color: if code-extra-colors.bg != none { + (code-extra-colors.bg, code-extra-colors.bg) + }, + lang: false, + numbering: false, + ) + } + + /// HTML code block supported by zebraw. + show: init-with-theme((code-extra-colors, is-dark-theme)) + + // code block setting + set raw(theme: theme-style.code-theme) if theme-style.code-theme.len() > 0 + show raw: set text(font: code-font) + show raw.where(block: true): it => context if shiroa-sys-target() == "paged" { + rect( + width: 100%, + inset: (x: 4pt, y: 5pt), + radius: 4pt, + fill: code-extra-colors.bg, + [ + #set text(fill: code-extra-colors.fg) if code-extra-colors.fg != none + #set par(justify: false) + // #place(right, text(luma(110), it.lang)) + #it + ], + ) + } else { + set text(fill: code-extra-colors.fg) if code-extra-colors.fg != none + set par(justify: false) + zebraw( + block-width: 100%, + // line-width: 100%, + wrap: false, + it, + ) + } + + body +} + +#let equation-rules(body) = { + // equation setting + show math.equation: set text(weight: 400) + show math.equation.where(block: true): it => context if shiroa-sys-target() == "html" { + div-frame(attrs: ("style": "display: flex; justify-content: center; overflow-x: auto;"), it) + } else { + it + } + show math.equation.where(block: false): it => context if shiroa-sys-target() == "html" { + span-frame(attrs: ("style": "overflow-x: auto;"), it) + } else { + it + } + + body +} + +#let md-equation-rules(body) = { + // equation setting + show math.equation: it => theme-box( + tag: if it.block { "p" } else { "span" }, + theme => { + set text(fill: if theme.is-dark { gh-dark-fg } else { theme.main-color }) + html.frame(it) + }, + ) + + body +} + +/// The project function defines how your document looks. +/// It takes your content and some metadata and formats it. +/// Go ahead and customize it to your liking! +#let project(title: "Tinymist Docs", authors: (), kind: "page", body) = { + // set basic document metadata + set document( + author: authors, + title: title, + ) if not is-pdf-target and not is-md-target + + // todo dirty hack to check is main + let is-main = title == "Tinymist Documentation" + + // set web/pdf page properties + set page( + numbering: none, + number-align: center, + width: page-width, + ) if not (sys-is-html-target or is-html-target) + set page(numbering: "1") if (not sys-is-html-target and is-pdf-target) and not is-main and kind == "page" + + // remove margins for web target + set page( + margin: ( + // reserved beautiful top margin + top: 20pt, + // reserved for our heading style. + // If you apply a different heading style, you may remove it. + left: 20pt, + // Typst is setting the page's bottom to the baseline of the last line of text. So bad :(. + bottom: 0.5em, + // remove rest margins. + rest: 0pt, + ), + height: auto, + ) if is-web-target and not is-html-target + + // Set main text + set text( + font: main-font, + size: main-size, + fill: main-color, + lang: "en", + ) + + // Set main spacing + set enum( + indent: list-indent * 0.618, + body-indent: list-indent, + ) + set list( + indent: list-indent * 0.618, + body-indent: list-indent, + ) + set par(leading: 0.7em) + set block(spacing: 0.7em * 1.5) + + // Set text, spacing for headings + // Render a dash to hint headings instead of bolding it as well if it's for web. + show heading: set text(weight: "regular") if is-web-target + show heading: it => { + set text(size: heading-sizes.at(it.level)) + + block( + spacing: 0.7em * 1.5 * 1.2, + below: 0.7em * 1.2, + { + // if is-web-target { + // heading-hash(it, hash-color: dash-color) + // } + + it + }, + ) + } + set heading( + numbering: (..numbers) => context { + if part-counter.get().at(0) > 0 { + numbering("1.", ..part-counter.get(), ..numbers) + } else { + h(-0.3em) + } + }, + ) if is-pdf-target + + // link setting + show link: set text(fill: dash-color) + + show: if is-md-target { + md-equation-rules + } else { + equation-rules + } + + show: if is-md-target { + it => it + } else { + raw-rules + } + + if not is-md-target { + context if shiroa-sys-target() == "html" { + show raw: it => html.elem("style", it.text) + ```css + .pseudo-image svg { + width: 100% + } + ``` + } + } + + show : it => { + it.lines.at(0).body.children.slice(0, -2).join() + } + + if kind == "page" and is-pdf-target and not is-main { + heading(level: 1, numbering: none, text(size: 32pt, title)) + } + + // Main body. + set par(justify: true) + + body +} + +#let part-style(it) = { + set text(size: heading-sizes.at(0)) + set text(weight: "bold") + set text(fill: main-color) + part-counter.step() + + context heading(numbering: none, [Part #part-counter.display(numbly("{1}. "))#it]) + counter(heading).update(0) +} diff --git a/typ/packages/package-docs/theme-style.toml b/typ/packages/package-docs/theme-style.toml new file mode 100644 index 00000000..128d0b17 --- /dev/null +++ b/typ/packages/package-docs/theme-style.toml @@ -0,0 +1,30 @@ + +[light] +color-scheme = "light" +main-color = "#000" +dash-color = "#20609f" +code-theme = "" + +[rust] +color-scheme = "light" +main-color = "#262625" +dash-color = "#2b79a2" +code-theme = "" + +[coal] +color-scheme = "dark" +main-color = "#98a3ad" +dash-color = "#2b79a2" +code-theme = "tokyo-night.tmTheme" + +[navy] +color-scheme = "dark" +main-color = "#bcbdd0" +dash-color = "#2b79a2" +code-theme = "tokyo-night.tmTheme" + +[ayu] +color-scheme = "dark" +main-color = "#c5c5c5" +dash-color = "#0096cf" +code-theme = "tokyo-night.tmTheme" diff --git a/typ/packages/package-docs/theme.typ b/typ/packages/package-docs/theme.typ new file mode 100644 index 00000000..8ef2a95e --- /dev/null +++ b/typ/packages/package-docs/theme.typ @@ -0,0 +1,55 @@ +#import "@preview/shiroa:0.2.3": templates, book-sys +#import templates: * + +#let is-md-target = book-sys.target == "md" +#let sys-is-html-target = book-sys.sys-is-html-target + +// Theme (Colors) +#let dark-theme = book-theme-from(toml("theme-style.toml"), xml: it => xml(it), target: "web-ayu") +#let light-theme = book-theme-from( + toml("theme-style.toml"), + xml: it => xml(it), + target: if sys-is-html-target { + "web-light" + } else { + "pdf" + }, +) +#let default-theme = if sys-is-html-target { + dark-theme +} else { + light-theme +} + +#let theme-box(render, tag: "div", theme-tag: none) = if is-md-target { + show: html.elem.with(tag) + show: html.elem.with("picture") + html.elem( + "m1source", + attrs: (media: "(prefers-color-scheme: dark)"), + render(dark-theme), + ) + render(light-theme) +} else if sys-is-html-target { + if theme-tag == none { + theme-tag = tag + } + html.elem( + tag, + attrs: (class: "code-image themed"), + { + html.elem( + theme-tag, + render(dark-theme), + attrs: (class: "dark"), + ) + html.elem( + theme-tag, + render(light-theme), + attrs: (class: "light"), + ) + }, + ) +} else { + render(default-theme) +} diff --git a/typ/packages/package-docs/tokyo-night.tmTheme b/typ/packages/package-docs/tokyo-night.tmTheme new file mode 100644 index 00000000..a144202b --- /dev/null +++ b/typ/packages/package-docs/tokyo-night.tmTheme @@ -0,0 +1,1308 @@ + + + + + name + Tokyo Night + settings + + + settings + + caret + #c0caf5 + selection + #515c7e4d + lineHighlight + #1e202e + foreground + #a9b1d6 + background + #1a1b26 + invisibles + #363b54 + + + + name + Italics - Comments, Storage, Keyword Flow, Vue attributes, Decorators + scope + comment,meta.var.expr storage.type,keyword.control.flow,keyword.control.return,meta.directive.vue punctuation.separator.key-value.html,meta.directive.vue entity.other.attribute-name.html,tag.decorator.js entity.name.tag.js,tag.decorator.js punctuation.definition.tag.js,storage.modifier + settings + + fontStyle + italic + + + + name + Fix YAML block scalar + scope + keyword.control.flow.block-scalar.literal + settings + + fontStyle + + + + + name + Comment + scope + comment,comment.block.documentation,punctuation.definition.comment,comment.block.documentation punctuation + settings + + foreground + #444b6a + + + + name + Comment Doc + scope + keyword.operator.assignment.jsdoc,comment.block.documentation variable,comment.block.documentation storage,comment.block.documentation keyword,comment.block.documentation support,comment.block.documentation markup,comment.block.documentation markup.inline.raw.string.markdown,meta.other.type.phpdoc.php keyword.other.type.php,meta.other.type.phpdoc.php support.other.namespace.php,meta.other.type.phpdoc.php punctuation.separator.inheritance.php,meta.other.type.phpdoc.php support.class,keyword.other.phpdoc.php,log.date + settings + + foreground + #5a638c + + + + name + Comment Doc Emphasized + scope + meta.other.type.phpdoc.php support.class,comment.block.documentation storage.type,comment.block.documentation punctuation.definition.block.tag,comment.block.documentation entity.name.type.instance + settings + + foreground + #646e9c + + + + name + Number, Boolean, Undefined, Null + scope + variable.other.constant,punctuation.definition.constant,constant.language,constant.numeric,support.constant + settings + + foreground + #ff9e64 + + + + name + String, Symbols + scope + string,constant.other.symbol,constant.other.key,meta.attribute-selector + settings + + fontStyle + + foreground + #9ece6a + + + + name + Colors + scope + constant.other.color,constant.other.color.rgb-value.hex punctuation.definition.constant + settings + + foreground + #9aa5ce + + + + name + Invalid + scope + invalid,invalid.illegal + settings + + foreground + #ff5370 + + + + name + Invalid deprecated + scope + invalid.deprecated + settings + + foreground + #bb9af7 + + + + name + Storage Type + scope + storage.type + settings + + foreground + #bb9af7 + + + + name + Storage - modifier, var, const, let + scope + meta.var.expr storage.type,storage.modifier + settings + + foreground + #9d7cd8 + + + + name + Interpolation, PHP tags, Smarty tags + scope + punctuation.definition.template-expression,punctuation.section.embedded,meta.embedded.line.tag.smarty,support.constant.handlebars,punctuation.section.tag.twig + settings + + foreground + #7dcfff + + + + name + Blade, Twig, Smarty Handlebars keywords + scope + keyword.control.smarty,keyword.control.twig,support.constant.handlebars keyword.control,keyword.operator.comparison.twig,keyword.blade,entity.name.function.blade + settings + + foreground + #0db9d7 + + + + name + Spread + scope + keyword.operator.spread,keyword.operator.rest + settings + + foreground + #f7768e + fontStyle + bold + + + + name + Operator, Misc + scope + keyword.operator,keyword.control.as,keyword.other,keyword.operator.bitwise.shift,punctuation,expression.embbeded.vue punctuation.definition.tag,text.html.twig meta.tag.inline.any.html,meta.tag.template.value.twig meta.function.arguments.twig,meta.directive.vue punctuation.separator.key-value.html,punctuation.definition.constant.markdown,punctuation.definition.string,punctuation.support.type.property-name,text.html.vue-html meta.tag,meta.attribute.directive,punctuation.definition.keyword,punctuation.terminator.rule,punctuation.definition.entity,punctuation.separator.inheritance.php,keyword.other.template,keyword.other.substitution,entity.name.operator,meta.property-list punctuation.separator.key-value,meta.at-rule.mixin punctuation.separator.key-value,meta.at-rule.function variable.parameter.url + settings + + foreground + #89ddff + + + + name + Import, Export, From, Default + scope + keyword.control.import,keyword.control.export,keyword.control.from,keyword.control.default,meta.import keyword.other + settings + + foreground + #7dcfff + + + + name + Keyword + scope + keyword,keyword.control,keyword.other.important + settings + + foreground + #bb9af7 + + + + name + Keyword SQL + scope + keyword.other.DML + settings + + foreground + #7dcfff + + + + name + Keyword Operator Logical, Arrow, Ternary, Comparison + scope + keyword.operator.logical,storage.type.function,keyword.operator.bitwise,keyword.operator.ternary,keyword.operator.comparison,keyword.operator.relational,keyword.operator.or.regexp + settings + + foreground + #bb9af7 + + + + name + Tag + scope + entity.name.tag + settings + + foreground + #f7768e + + + + name + Tag - Custom + scope + entity.name.tag support.class.component,meta.tag.custom entity.name.tag,meta.tag + settings + + foreground + #de5971 + + + + name + Tag Punctuation + scope + punctuation.definition.tag + settings + + foreground + #ba3c97 + + + + name + Globals, PHP Constants, etc + scope + constant.other.php,variable.other.global.safer,variable.other.global.safer punctuation.definition.variable,variable.other.global,variable.other.global punctuation.definition.variable,constant.other + settings + + foreground + #e0af68 + + + + name + Variables + scope + variable,support.variable,string constant.other.placeholder,variable.parameter.handlebars,variable.other.object + settings + + foreground + #c0caf5 + + + + name + Variable Array Key + scope + meta.array.literal variable + settings + + foreground + #7dcfff + + + + name + Object Key + scope + meta.object-literal.key,entity.name.type.hcl,string.alias.graphql,string.unquoted.graphql,string.unquoted.alias.graphql,meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js,meta.field.declaration.ts variable.object.property,meta.block entity.name.label + settings + + foreground + #73daca + + + + name + Object Property + scope + variable.other.property,support.variable.property,support.variable.property.dom,meta.function-call variable.other.object.property + settings + + foreground + #7dcfff + + + + name + Object Property + scope + variable.other.object.property + settings + + foreground + #c0caf5 + + + + name + Object Literal Member lvl 3 (Vue Prop Validation) + scope + meta.objectliteral meta.object.member meta.objectliteral meta.object.member meta.objectliteral meta.object.member meta.object-literal.key + settings + + foreground + #41a6b5 + + + + name + C-related Block Level Variables + scope + source.cpp meta.block variable.other + settings + + foreground + #f7768e + + + + name + Other Variable + scope + support.other.variable + settings + + foreground + #f7768e + + + + name + Methods + scope + meta.class-method.js entity.name.function.js,entity.name.method.js,variable.function.constructor,keyword.other.special-method,storage.type.cs + settings + + foreground + #7aa2f7 + + + + name + Function Definition + scope + entity.name.function,variable.other.enummember,meta.function-call,meta.function-call entity.name.function,variable.function,meta.definition.method entity.name.function,meta.object-literal entity.name.function + settings + + foreground + #7aa2f7 + + + + name + Function Argument + scope + variable.parameter.function.language.special,variable.parameter,meta.function.parameters punctuation.definition.variable,meta.function.parameter variable + settings + + foreground + #e0af68 + + + + name + Constant, Tag Attribute + scope + keyword.other.type.php,storage.type.php,constant.character,constant.escape,keyword.other.unit + settings + + foreground + #bb9af7 + + + + name + Variable Definition + scope + meta.definition.variable variable.other.constant,meta.definition.variable variable.other.readwrite,variable.declaration.hcl variable.other.readwrite.hcl,meta.mapping.key.hcl variable.other.readwrite.hcl,variable.other.declaration + settings + + foreground + #bb9af7 + + + + name + Inherited Class + scope + entity.other.inherited-class + settings + + fontStyle + + foreground + #bb9af7 + + + + name + Class, Support, DOM, etc + scope + support.class,support.type,variable.other.readwrite.alias,support.orther.namespace.use.php,meta.use.php,support.other.namespace.php,support.type.sys-types,support.variable.dom,support.constant.math,support.type.object.module,support.constant.json,entity.name.namespace,meta.import.qualifier,variable.other.constant.object + settings + + foreground + #0db9d7 + + + + name + Class Name + scope + entity.name + settings + + foreground + #c0caf5 + + + + name + Support Function + scope + support.function + settings + + foreground + #0db9d7 + + + + name + CSS Class and Support + scope + source.css support.type.property-name,source.sass support.type.property-name,source.scss support.type.property-name,source.less support.type.property-name,source.stylus support.type.property-name,source.postcss support.type.property-name,support.type.property-name.css,support.type.vendored.property-name,support.type.map.key + settings + + foreground + #7aa2f7 + + + + name + CSS Font + scope + support.constant.font-name,meta.definition.variable + settings + + foreground + #9ece6a + + + + name + CSS Class + scope + entity.other.attribute-name.class,meta.at-rule.mixin.scss entity.name.function.scss + settings + + foreground + #9ece6a + + + + name + CSS ID + scope + entity.other.attribute-name.id + settings + + foreground + #fc7b7b + + + + name + CSS Tag + scope + entity.name.tag.css + settings + + foreground + #0db9d7 + + + + name + CSS Tag Reference, Pseudo & Class Punctuation + scope + entity.other.attribute-name.pseudo-class punctuation.definition.entity,entity.other.attribute-name.pseudo-element punctuation.definition.entity,entity.other.attribute-name.class punctuation.definition.entity,entity.name.tag.reference + settings + + foreground + #e0af68 + + + + name + CSS Punctuation + scope + meta.property-list + settings + + foreground + #9abdf5 + + + + name + CSS at-rule fix + scope + meta.property-list meta.at-rule.if,meta.at-rule.return variable.parameter.url,meta.property-list meta.at-rule.else + settings + + foreground + #ff9e64 + + + + name + CSS Parent Selector Entity + scope + entity.other.attribute-name.parent-selector-suffix punctuation.definition.entity.css + settings + + foreground + #73daca + + + + name + CSS Punctuation comma fix + scope + meta.property-list meta.property-list + settings + + foreground + #9abdf5 + + + + name + SCSS @ + scope + meta.at-rule.mixin keyword.control.at-rule.mixin,meta.at-rule.include entity.name.function.scss,meta.at-rule.include keyword.control.at-rule.include + settings + + foreground + #bb9af7 + + + + name + SCSS Mixins, Extends, Include Keyword + scope + keyword.control.at-rule.include punctuation.definition.keyword,keyword.control.at-rule.mixin punctuation.definition.keyword,meta.at-rule.include keyword.control.at-rule.include,keyword.control.at-rule.extend punctuation.definition.keyword,meta.at-rule.extend keyword.control.at-rule.extend,entity.other.attribute-name.placeholder.css punctuation.definition.entity.css,meta.at-rule.media keyword.control.at-rule.media,meta.at-rule.mixin keyword.control.at-rule.mixin,meta.at-rule.function keyword.control.at-rule.function,keyword.control punctuation.definition.keyword + settings + + foreground + #9d7cd8 + + + + name + SCSS Include Mixin Argument + scope + meta.property-list meta.at-rule.include + settings + + foreground + #c0caf5 + + + + name + CSS value + scope + support.constant.property-value + settings + + foreground + #ff9e64 + + + + name + Sub-methods + scope + entity.name.module.js,variable.import.parameter.js,variable.other.class.js + settings + + foreground + #c0caf5 + + + + name + Language methods + scope + variable.language + settings + + foreground + #f7768e + + + + name + Variable punctuation + scope + variable.other punctuation.definition.variable + settings + + foreground + #c0caf5 + + + + name + Keyword this with Punctuation, ES7 Bind Operator + scope + source.js constant.other.object.key.js string.unquoted.label.js,variable.language.this punctuation.definition.variable,keyword.other.this + settings + + foreground + #f7768e + + + + name + HTML Attributes + scope + entity.other.attribute-name,text.html.basic entity.other.attribute-name.html,text.html.basic entity.other.attribute-name + settings + + foreground + #bb9af7 + + + + name + HTML Character Entity + scope + text.html constant.character.entity + settings + + foreground + #0DB9D7 + + + + name + Vue (Vetur / deprecated) Template attributes + scope + entity.other.attribute-name.id.html,meta.directive.vue entity.other.attribute-name.html + settings + + foreground + #bb9af7 + + + + name + CSS ID's + scope + source.sass keyword.control + settings + + foreground + #7aa2f7 + + + + name + CSS pseudo selectors + scope + entity.other.attribute-name.pseudo-class,entity.other.attribute-name.pseudo-element,entity.other.attribute-name.placeholder,meta.property-list meta.property-value + settings + + foreground + #bb9af7 + + + + name + Inserted + scope + markup.inserted + settings + + foreground + #449dab + + + + name + Deleted + scope + markup.deleted + settings + + foreground + #914c54 + + + + name + Changed + scope + markup.changed + settings + + foreground + #6183bb + + + + name + Regular Expressions + scope + string.regexp + settings + + foreground + #b4f9f8 + + + + name + Regular Expressions - Punctuation + scope + punctuation.definition.group + settings + + foreground + #f7768e + + + + name + Regular Expressions - Character Class + scope + constant.other.character-class.regexp + settings + + foreground + #bb9af7 + + + + name + Regular Expressions - Character Class Set + scope + constant.other.character-class.set.regexp,punctuation.definition.character-class.regexp + settings + + foreground + #e0af68 + + + + name + Regular Expressions - Quantifier + scope + keyword.operator.quantifier.regexp + settings + + foreground + #89ddff + + + + name + Regular Expressions - Backslash + scope + constant.character.escape.backslash + settings + + foreground + #c0caf5 + + + + name + Escape Characters + scope + constant.character.escape + settings + + foreground + #89ddff + + + + name + Decorators + scope + tag.decorator.js entity.name.tag.js,tag.decorator.js punctuation.definition.tag.js + settings + + foreground + #7aa2f7 + + + + name + CSS Units + scope + keyword.other.unit + settings + + foreground + #f7768e + + + + name + JSON Key - Level 0 + scope + source.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #7aa2f7 + + + + name + JSON Key - Level 1 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #0db9d7 + + + + name + JSON Key - Level 2 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #7dcfff + + + + name + JSON Key - Level 3 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #bb9af7 + + + + name + JSON Key - Level 4 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #e0af68 + + + + name + JSON Key - Level 5 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #0db9d7 + + + + name + JSON Key - Level 6 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #73daca + + + + name + JSON Key - Level 7 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #f7768e + + + + name + JSON Key - Level 8 + scope + source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json + settings + + foreground + #9ece6a + + + + name + Plain Punctuation + scope + punctuation.definition.list_item.markdown + settings + + foreground + #9abdf5 + + + + name + Block Punctuation + scope + meta.block,meta.brace,punctuation.definition.block,punctuation.definition.use,punctuation.definition.class,punctuation.definition.begin.bracket,punctuation.definition.end.bracket,punctuation.definition.switch-expression.begin.bracket,punctuation.definition.switch-expression.end.bracket,punctuation.definition.section.switch-block.begin.bracket,punctuation.definition.section.switch-block.end.bracket,punctuation.definition.group.shell,punctuation.definition.parameters,punctuation.definition.arguments,punctuation.definition.dictionary,punctuation.definition.array,punctuation.section + settings + + foreground + #9abdf5 + + + + name + Markdown - Plain + scope + meta.jsx.children,meta.embedded.block + settings + + foreground + #c0caf5 + + + + name + HTML text + scope + text.html,text.log + settings + + foreground + #9aa5ce + + + + name + Markdown - Markup Raw Inline + scope + text.html.markdown markup.inline.raw.markdown + settings + + foreground + #bb9af7 + + + + name + Markdown - Markup Raw Inline Punctuation + scope + text.html.markdown markup.inline.raw.markdown punctuation.definition.raw.markdown + settings + + foreground + #4E5579 + + + + name + Markdown - Heading 1 + scope + heading.1.markdown entity.name,heading.1.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #89ddff + + + + name + Markdown - Heading 2 + scope + heading.2.markdown entity.name,heading.2.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #61bdf2 + + + + name + Markdown - Heading 3 + scope + heading.3.markdown entity.name,heading.3.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #7aa2f7 + + + + name + Markdown - Heading 4 + scope + heading.4.markdown entity.name,heading.4.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #6d91de + + + + name + Markdown - Heading 5 + scope + heading.5.markdown entity.name,heading.5.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #9aa5ce + + + + name + Markdown - Heading 6 + scope + heading.6.markdown entity.name,heading.6.markdown punctuation.definition.heading.markdown + settings + + fontStyle + bold + foreground + #747ca1 + + + + name + Markup - Italic + scope + markup.italic,markup.italic punctuation + settings + + fontStyle + italic + foreground + #c0caf5 + + + + name + Markup - Bold + scope + markup.bold,markup.bold punctuation + settings + + fontStyle + bold + foreground + #c0caf5 + + + + name + Markup - Bold-Italic + scope + markup.bold markup.italic,markup.bold markup.italic punctuation + settings + + fontStyle + bold italic + foreground + #c0caf5 + + + + name + Markup - Underline + scope + markup.underline,markup.underline punctuation + settings + + fontStyle + underline + + + + name + Markdown - Blockquote + scope + markup.quote punctuation.definition.blockquote.markdown + settings + + foreground + #4e5579 + + + + name + Markup - Quote + scope + markup.quote + settings + + fontStyle + italic + + + + name + Markdown - Link + scope + string.other.link,markup.underline.link,constant.other.reference.link.markdown,string.other.link.description.title.markdown + settings + + foreground + #73daca + + + + name + Markdown - Fenced Code Block + scope + markup.fenced_code.block.markdown,markup.inline.raw.string.markdown,variable.language.fenced.markdown + settings + + foreground + #89ddff + + + + name + Markdown - Separator + scope + meta.separator + settings + + fontStyle + bold + foreground + #444b6a + + + + name + Markup - Table + scope + markup.table + settings + + foreground + #c0cefc + + + + name + Token - Info + scope + token.info-token + settings + + foreground + #0db9d7 + + + + name + Token - Warn + scope + token.warn-token + settings + + foreground + #ffdb69 + + + + name + Token - Error + scope + token.error-token + settings + + foreground + #db4b4b + + + + name + Token - Debug + scope + token.debug-token + settings + + foreground + #b267e6 + + + + name + Apache Tag + scope + entity.tag.apacheconf + settings + + foreground + #f7768e + + + + name + Preprocessor + scope + meta.preprocessor + settings + + foreground + #73daca + + + + name + ENV value + scope + source.env + settings + + foreground + #7aa2f7 + + + + + diff --git a/typ/packages/package-docs/typst.toml b/typ/packages/package-docs/typst.toml new file mode 100644 index 00000000..7ef016b4 --- /dev/null +++ b/typ/packages/package-docs/typst.toml @@ -0,0 +1,4 @@ +[package] +name = "package-docs" +version = "0.1.0" +entrypoint = "main.typ"