Skip to content
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
4 changes: 2 additions & 2 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0-only"
# Consumed by git rev (see ComlineProject/docs → Design → Runtime & generation
# repository structure — no crates.io publishing at this stage). Local
# iteration: add a `[patch]` onto a sibling checkout.
comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "cd63473e7029542ef1358accbc5fc61059824577" }
comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "3ad2c79f48242f7de4bed3e8bc23c5673a381a2e" }
comline-core = { git = "https://github.com/ComlineProject/core", rev = "263e58378bb7efcaa466542ca644228ad14e2884", default-features = false }

eyre = "0.6.8"
Expand All @@ -21,6 +21,6 @@ path = "src/bin/comline-gen-typescript.rs"
# The conformance corpus: every fixture is a whole package. Same generation
# rev as `comline-codegen` above, so the corpus and the generator share one
# `comline-codegen`.
comline-conformance = { git = "https://github.com/ComlineProject/generation", rev = "cd63473e7029542ef1358accbc5fc61059824577" }
comline-conformance = { git = "https://github.com/ComlineProject/generation", rev = "3ad2c79f48242f7de4bed3e8bc23c5673a381a2e" }
# The tests compile schemas, so they need core's compiler.
comline-core = { git = "https://github.com/ComlineProject/core", rev = "263e58378bb7efcaa466542ca644228ad14e2884" }
8 changes: 8 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
mod generator;
mod ident;

use comline_codegen::docs::{DocsTable, Topic};
use comline_codegen::features::{Feature, Support, SupportTable};
use comline_codegen::versions::Versions;
use comline_codegen::Generator;
Expand Down Expand Up @@ -81,6 +82,12 @@ pub const SUPPORT: SupportTable = &[
(Feature::Chars, Support::supported()),
];

/// The documentation pages this generator points users at, by topic.
pub const DOCS: DocsTable = &[(
Topic::Connections,
"https://comlineproject.github.io/docs/languages/typescript/connections/#when-theyre-generated",
)];

/// Contribute the TypeScript generator to a CLI's [`Registry`](comline_codegen::Registry),
/// as `typescript` and `ts`.
pub fn register(registry: &mut comline_codegen::Registry) {
Expand All @@ -91,6 +98,7 @@ pub fn register(registry: &mut comline_codegen::Registry) {
generate: generate_typescript,
support: SUPPORT,
versions: VERSIONS,
docs: DOCS,
});
}
}
19 changes: 17 additions & 2 deletions codegen/tests/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use std::io::Write;
use std::process::{Command, Stdio};

use comline_codegen::protocol::{decode, encode, FileOut, Request, Response};
use comline_codegen::{GenerateRequest, PackageMeta, TargetLanguage};
use comline_codegen::docs::Topic;
use comline_codegen::protocol::{decode, describe, encode, FileOut, Request, Response};
use comline_codegen::{GenerateRequest, PackageMeta, Registry, TargetLanguage};
use comline_codegen_typescript::{generate_typescript, VERSIONS};
use comline_conformance::{corpus, Fixture};
use comline_core::schema::idl::annotations::DEFAULT_FORMAT;
Expand Down Expand Up @@ -73,6 +74,20 @@ fn the_binary_describes_the_typescript_generator() {
assert!(d.languages.iter().all(|l| l.versions.floor == VERSIONS.floor));
}

#[test]
fn every_registered_name_carries_the_connections_docs_link() {
let mut registry = Registry::new();
comline_codegen_typescript::register(&mut registry);
let languages = describe(&registry).languages;
assert_eq!(languages.len(), 2);
for language in &languages {
assert_eq!(
language.doc(Topic::Connections),
Some("https://comlineproject.github.io/docs/languages/typescript/connections/#when-theyre-generated")
);
}
}

#[test]
fn the_ts_alias_generates_the_same() {
let fx = corpus().into_iter().next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
# Same revs `codegen` pins, so this tool and the generator it drives agree on
# one `comline-core` - see codegen/Cargo.toml's own comment.
comline-core = { git = "https://github.com/ComlineProject/core", rev = "263e58378bb7efcaa466542ca644228ad14e2884" }
comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "cd63473e7029542ef1358accbc5fc61059824577" }
comline-codegen = { git = "https://github.com/ComlineProject/generation", rev = "3ad2c79f48242f7de4bed3e8bc23c5673a381a2e" }
comline-codegen-typescript = { path = "../codegen" }

eyre = "0.6.8"
Loading