-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jsdoc typedefs * correct default features * fix tests * make datatype available to js and ts * clippy * Move `js_doc` back to `ts` It makes the public API sooo cringe. Also `js_doc` depending on `typescript` as a feature is expected. * Do you have a moment for our lord Clippy? * Rename feature from `js` to `js_doc` * No default `serde` feature * Taplo config + Drop `indoc` and `const_format` deps * future me problem * Let's be extra explicit * why da fuk did I put `BigIntExportBehavior` in `comments.fs` + qualify `ts::comments` * nit * potentially maybe kinda possibly fix trybuild * remove empty_tuple_fallback * remove all empty_tuple_fallback * fix * trybuild * fix js doc generics * fix trybuild output Rust version mismatch lol --------- Co-authored-by: Oscar Beaumont <[email protected]>
- Loading branch information
1 parent
298c904
commit b474b8e
Showing
19 changed files
with
230 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[formatting] | ||
column_width = 150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::borrow::Cow; | ||
|
||
use crate::*; | ||
|
||
pub use super::ts::*; | ||
|
||
pub fn format_comment(cfg: &ExportConfig, typ: &NamedDataType, type_map: &TypeMap) -> Output { | ||
format_comment_inner(&ExportContext { cfg, path: vec![] }, typ, type_map) | ||
} | ||
|
||
fn format_comment_inner( | ||
ctx: &ExportContext, | ||
typ @ NamedDataType { | ||
name, | ||
comments, | ||
inner: item, | ||
.. | ||
}: &NamedDataType, | ||
type_map: &TypeMap, | ||
) -> Output { | ||
let ctx = ctx.with(PathItem::Type(name.clone())); | ||
|
||
let name = sanitise_type_name(ctx.clone(), NamedLocation::Type, name)?; | ||
|
||
let inline_ts = datatype_inner(ctx.clone(), &typ.inner, type_map)?; | ||
|
||
// TODO: Export deprecated | ||
|
||
Ok(comments::js_doc( | ||
&comments | ||
.iter() | ||
.cloned() | ||
.chain( | ||
item.generics() | ||
.map(|generics| { | ||
generics | ||
.iter() | ||
.map(|generic| Cow::Owned(format!("@template {}", generic))) | ||
.collect::<Vec<_>>() // TODO: We should be able to avoid this alloc with some work | ||
}) | ||
.unwrap_or_default(), | ||
) | ||
.chain([format!(r#"@typedef {{ {inline_ts} }} {name}"#).into()]) | ||
.collect::<Vec<_>>(), | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use crate::*; | ||
use indoc::*; | ||
|
||
/// TODO | ||
pub fn export<T: Type>() -> Result<String, String> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.