From f5af22ef716db76a39ea22cc88f3f92745fb4aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sat, 27 Nov 2021 16:55:42 +0900 Subject: [PATCH] chore: Document features (#2890) --- Cargo.lock | 12 ++++++------ crates/swc_common/Cargo.toml | 2 +- crates/swc_common/src/errors/emitter.rs | 1 + crates/swc_common/src/errors/mod.rs | 2 ++ crates/swc_common/src/lib.rs | 3 ++- crates/swc_common/src/plugin.rs | 2 ++ crates/swc_common/src/source_map.rs | 3 +++ crates/swc_common/src/syntax_pos.rs | 1 + crates/swc_common/src/syntax_pos/hygiene.rs | 1 + crates/swc_css_parser/src/lib.rs | 1 + crates/swc_ecma_ast/Cargo.toml | 2 +- crates/swc_ecma_ast/src/ident.rs | 1 + crates/swc_ecma_ast/src/jsx.rs | 1 + crates/swc_ecma_ast/src/lib.rs | 1 + crates/swc_ecma_ast/src/lit.rs | 3 +++ crates/swc_ecma_ast/src/macros.rs | 3 ++- crates/swc_ecma_ast/src/module.rs | 2 ++ crates/swc_ecma_loader/Cargo.toml | 2 +- crates/swc_ecma_loader/src/lib.rs | 2 ++ crates/swc_ecma_loader/src/resolvers/mod.rs | 3 +++ crates/swc_ecma_parser/Cargo.toml | 2 +- crates/swc_ecma_parser/src/lib.rs | 2 ++ crates/swc_ecma_transforms/Cargo.toml | 2 +- crates/swc_ecma_transforms/src/lib.rs | 8 ++++++++ crates/swc_ecmascript/Cargo.toml | 2 +- crates/swc_ecmascript/src/lib.rs | 10 ++++++++++ 26 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 277af0f30fd..a3e366d27a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2538,7 +2538,7 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.14.6" +version = "0.14.7" dependencies = [ "abi_stable", "ahash", @@ -2670,7 +2670,7 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.58.0" +version = "0.58.1" dependencies = [ "arbitrary", "is-macro", @@ -2739,7 +2739,7 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.24.3" +version = "0.24.4" dependencies = [ "ahash", "anyhow", @@ -2792,7 +2792,7 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.78.9" +version = "0.78.10" dependencies = [ "either", "enum_kind", @@ -2862,7 +2862,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.95.1" +version = "0.95.2" dependencies = [ "pretty_assertions 0.6.1", "sourcemap", @@ -3133,7 +3133,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.88.1" +version = "0.88.2" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", diff --git a/crates/swc_common/Cargo.toml b/crates/swc_common/Cargo.toml index 8222cdadcaf..2bc3d4f0ab8 100644 --- a/crates/swc_common/Cargo.toml +++ b/crates/swc_common/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_common" repository = "https://github.com/swc-project/swc.git" -version = "0.14.6" +version = "0.14.7" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_common/src/errors/emitter.rs b/crates/swc_common/src/errors/emitter.rs index 148b3b977a5..ac8aab2feee 100644 --- a/crates/swc_common/src/errors/emitter.rs +++ b/crates/swc_common/src/errors/emitter.rs @@ -150,6 +150,7 @@ struct FileWithAnnotatedLines { } #[cfg(feature = "tty-emitter")] +#[cfg_attr(docsrs, doc(cfg(feature = "tty-emitter")))] impl EmitterWriter { pub fn stderr( color_config: ColorConfig, diff --git a/crates/swc_common/src/errors/mod.rs b/crates/swc_common/src/errors/mod.rs index 57f70567f08..7bd225d7d9e 100644 --- a/crates/swc_common/src/errors/mod.rs +++ b/crates/swc_common/src/errors/mod.rs @@ -349,6 +349,7 @@ impl Drop for Handler { impl Handler { #[cfg(feature = "tty-emitter")] + #[cfg_attr(docsrs, doc(cfg(feature = "tty-emitter")))] pub fn with_tty_emitter( color_config: ColorConfig, can_emit_warnings: bool, @@ -367,6 +368,7 @@ impl Handler { } #[cfg(feature = "tty-emitter")] + #[cfg_attr(docsrs, doc(cfg(feature = "tty-emitter")))] pub fn with_tty_emitter_and_flags( color_config: ColorConfig, cm: Option>, diff --git a/crates/swc_common/src/lib.rs b/crates/swc_common/src/lib.rs index f734565ea69..13c0d3d0d1c 100644 --- a/crates/swc_common/src/lib.rs +++ b/crates/swc_common/src/lib.rs @@ -27,7 +27,7 @@ //! //! Allows replacing operations related to thread-local variables with a trait. #![deny(unused)] - +#![cfg_attr(docsrs, feature(doc_cfg))] pub use self::{ eq::{EqIgnoreSpan, TypeEq}, errors::{SourceMapper, SourceMapperDyn}, @@ -62,6 +62,7 @@ pub mod iter; pub mod macros; pub mod pass; #[cfg(feature = "plugin-base")] +#[cfg_attr(docsrs, doc(cfg(any(feature = "plugin-rt", feature = "plugin-mode"))))] pub mod plugin; mod pos; mod rustc_data_structures; diff --git a/crates/swc_common/src/plugin.rs b/crates/swc_common/src/plugin.rs index 8927f2ad2fa..a1a8fa8a2ef 100644 --- a/crates/swc_common/src/plugin.rs +++ b/crates/swc_common/src/plugin.rs @@ -74,6 +74,7 @@ impl crate::errors::Emitter for PluginEmitter { } } +#[cfg_attr(docsrs, doc(cfg(feature = "plugin-mode")))] #[cfg(feature = "plugin-mode")] pub fn with_runtime(rt: &Runtime, op: F) -> Ret where @@ -168,6 +169,7 @@ impl RuntimeImpl for PluginRt { } } +#[cfg_attr(docsrs, doc(cfg(feature = "plugin-rt")))] #[cfg(feature = "plugin-rt")] pub fn get_runtime_for_plugin(plugin_name: String) -> Runtime { use abi_stable::erased_types::TD_Opaque; diff --git a/crates/swc_common/src/source_map.rs b/crates/swc_common/src/source_map.rs index a896fd667b7..626a9d77f37 100644 --- a/crates/swc_common/src/source_map.rs +++ b/crates/swc_common/src/source_map.rs @@ -1070,12 +1070,14 @@ impl SourceMap { /// #[cfg(feature = "sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] pub fn build_source_map(&self, mappings: &mut Vec<(BytePos, LineCol)>) -> sourcemap::SourceMap { self.build_source_map_from(mappings, None) } /// Creates a `.map` file. #[cfg(feature = "sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] pub fn build_source_map_from( &self, mappings: &mut Vec<(BytePos, LineCol)>, @@ -1085,6 +1087,7 @@ impl SourceMap { } #[cfg(feature = "sourcemap")] + #[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))] pub fn build_source_map_with_config( &self, mappings: &mut Vec<(BytePos, LineCol)>, diff --git a/crates/swc_common/src/syntax_pos.rs b/crates/swc_common/src/syntax_pos.rs index 03e473b2a64..a49384eda5e 100644 --- a/crates/swc_common/src/syntax_pos.rs +++ b/crates/swc_common/src/syntax_pos.rs @@ -39,6 +39,7 @@ pub struct Span { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Span { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let lo = u.arbitrary::()?; diff --git a/crates/swc_common/src/syntax_pos/hygiene.rs b/crates/swc_common/src/syntax_pos/hygiene.rs index 660fa58e47c..6e4d8d297ea 100644 --- a/crates/swc_common/src/syntax_pos/hygiene.rs +++ b/crates/swc_common/src/syntax_pos/hygiene.rs @@ -32,6 +32,7 @@ use std::{ pub struct SyntaxContext(u32); #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for SyntaxContext { fn arbitrary(_: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(SyntaxContext::empty()) diff --git a/crates/swc_css_parser/src/lib.rs b/crates/swc_css_parser/src/lib.rs index e35d5a7d020..fb036105b32 100644 --- a/crates/swc_css_parser/src/lib.rs +++ b/crates/swc_css_parser/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] #![deny(unused_must_use)] use crate::{ diff --git a/crates/swc_ecma_ast/Cargo.toml b/crates/swc_ecma_ast/Cargo.toml index 5f35f9ea0e1..d9a60c45e11 100644 --- a/crates/swc_ecma_ast/Cargo.toml +++ b/crates/swc_ecma_ast/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_ast" repository = "https://github.com/swc-project/swc.git" -version = "0.58.0" +version = "0.58.1" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_ecma_ast/src/ident.rs b/crates/swc_ecma_ast/src/ident.rs index 9261436b43e..af04fe793b2 100644 --- a/crates/swc_ecma_ast/src/ident.rs +++ b/crates/swc_ecma_ast/src/ident.rs @@ -85,6 +85,7 @@ impl Display for Ident { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Ident { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; diff --git a/crates/swc_ecma_ast/src/jsx.rs b/crates/swc_ecma_ast/src/jsx.rs index fae9682cba3..e935aba59d4 100644 --- a/crates/swc_ecma_ast/src/jsx.rs +++ b/crates/swc_ecma_ast/src/jsx.rs @@ -201,6 +201,7 @@ pub struct JSXText { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for JSXText { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index 7076217c802..27e3e662c55 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] #![deny(unreachable_patterns)] #![deny(missing_copy_implementations)] #![deny(missing_debug_implementations)] diff --git a/crates/swc_ecma_ast/src/lit.rs b/crates/swc_ecma_ast/src/lit.rs index 1ad44ff6ba7..8d8bbe79311 100644 --- a/crates/swc_ecma_ast/src/lit.rs +++ b/crates/swc_ecma_ast/src/lit.rs @@ -43,6 +43,7 @@ pub struct BigInt { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for BigInt { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; @@ -116,6 +117,7 @@ impl Default for StrKind { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Str { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; @@ -180,6 +182,7 @@ pub struct Regex { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Regex { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; diff --git a/crates/swc_ecma_ast/src/macros.rs b/crates/swc_ecma_ast/src/macros.rs index d036bdc5389..d2149fbbb0f 100644 --- a/crates/swc_ecma_ast/src/macros.rs +++ b/crates/swc_ecma_ast/src/macros.rs @@ -1,4 +1,5 @@ -/// Creates a corresponding operator. +/// Creates a corresponding operator. This macro is used to make code more +/// readable. /// /// This can used to represent [UnaryOp](crate::UnaryOp), /// [BinaryOp](crate::BinaryOp), or [AssignOp](crate::AssignOp). diff --git a/crates/swc_ecma_ast/src/module.rs b/crates/swc_ecma_ast/src/module.rs index 6a72c838698..39be0281e94 100644 --- a/crates/swc_ecma_ast/src/module.rs +++ b/crates/swc_ecma_ast/src/module.rs @@ -25,6 +25,7 @@ pub struct Module { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Module { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; @@ -59,6 +60,7 @@ pub struct Script { } #[cfg(feature = "arbitrary")] +#[cfg_attr(docsrs, doc(cfg(feature = "arbitrary")))] impl<'a> arbitrary::Arbitrary<'a> for Script { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let span = u.arbitrary()?; diff --git a/crates/swc_ecma_loader/Cargo.toml b/crates/swc_ecma_loader/Cargo.toml index ad289c13b96..1d60b4661f7 100644 --- a/crates/swc_ecma_loader/Cargo.toml +++ b/crates/swc_ecma_loader/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_loader" repository = "https://github.com/swc-project/swc.git" -version = "0.24.3" +version = "0.24.4" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_ecma_loader/src/lib.rs b/crates/swc_ecma_loader/src/lib.rs index 078d4b92d2f..97b51f3fdc6 100644 --- a/crates/swc_ecma_loader/src/lib.rs +++ b/crates/swc_ecma_loader/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] + use serde::{Deserialize, Serialize}; pub mod resolve; diff --git a/crates/swc_ecma_loader/src/resolvers/mod.rs b/crates/swc_ecma_loader/src/resolvers/mod.rs index 3055e2c5a1b..c4c3f30d16c 100644 --- a/crates/swc_ecma_loader/src/resolvers/mod.rs +++ b/crates/swc_ecma_loader/src/resolvers/mod.rs @@ -1,6 +1,9 @@ #[cfg(feature = "lru")] +#[cfg_attr(docsrs, doc(cfg(feature = "lru")))] pub mod lru; #[cfg(feature = "node")] +#[cfg_attr(docsrs, doc(cfg(feature = "node")))] pub mod node; #[cfg(feature = "tsc")] +#[cfg_attr(docsrs, doc(cfg(feature = "tsc")))] pub mod tsc; diff --git a/crates/swc_ecma_parser/Cargo.toml b/crates/swc_ecma_parser/Cargo.toml index 1e489f2d8f1..742a792d1c4 100644 --- a/crates/swc_ecma_parser/Cargo.toml +++ b/crates/swc_ecma_parser/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.78.9" +version = "0.78.10" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_ecma_parser/src/lib.rs b/crates/swc_ecma_parser/src/lib.rs index 2ab2b09fd21..a2b4c12a277 100644 --- a/crates/swc_ecma_parser/src/lib.rs +++ b/crates/swc_ecma_parser/src/lib.rs @@ -103,6 +103,7 @@ //! //! [tc39/test262]:https://github.com/tc39/test262 +#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(test, feature(bench_black_box))] #![cfg_attr(test, feature(test))] #![deny(unused)] @@ -131,6 +132,7 @@ pub enum Syntax { Es(EsConfig), /// This variant requires the cargo feature `typescript` to be enabled. #[cfg(feature = "typescript")] + #[cfg_attr(docsrs, doc(cfg(feature = "typescript")))] #[serde(rename = "typescript")] Typescript(TsConfig), } diff --git a/crates/swc_ecma_transforms/Cargo.toml b/crates/swc_ecma_transforms/Cargo.toml index 14ef1cbd78c..bb633e51add 100644 --- a/crates/swc_ecma_transforms/Cargo.toml +++ b/crates/swc_ecma_transforms/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms" repository = "https://github.com/swc-project/swc.git" -version = "0.95.1" +version = "0.95.2" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_ecma_transforms/src/lib.rs b/crates/swc_ecma_transforms/src/lib.rs index d170fd3f3d2..97d9456b89c 100644 --- a/crates/swc_ecma_transforms/src/lib.rs +++ b/crates/swc_ecma_transforms/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] #![deny(unused)] pub use self::{ @@ -7,16 +8,23 @@ pub use self::{ }; pub use swc_ecma_transforms_base::{fixer, helpers, hygiene, pass, perf, resolver}; #[cfg(feature = "swc_ecma_transforms_compat")] +#[cfg_attr(docsrs, doc(cfg(feature = "compat")))] pub use swc_ecma_transforms_compat as compat; #[cfg(feature = "swc_ecma_transforms_module")] +#[cfg_attr(docsrs, doc(cfg(feature = "module")))] pub use swc_ecma_transforms_module as modules; #[cfg(feature = "swc_ecma_transforms_optimization")] +#[cfg_attr(docsrs, doc(cfg(feature = "optimization")))] pub use swc_ecma_transforms_optimization as optimization; #[cfg(feature = "swc_ecma_transforms_optimization")] +#[cfg_attr(docsrs, doc(cfg(feature = "optimization")))] pub use swc_ecma_transforms_optimization::const_modules; #[cfg(feature = "swc_ecma_transforms_proposal")] +#[cfg_attr(docsrs, doc(cfg(feature = "proposal")))] pub use swc_ecma_transforms_proposal as proposals; #[cfg(feature = "swc_ecma_transforms_react")] pub use swc_ecma_transforms_react as react; +#[cfg_attr(docsrs, doc(cfg(feature = "react")))] #[cfg(feature = "swc_ecma_transforms_typescript")] +#[cfg_attr(docsrs, doc(cfg(feature = "typescript")))] pub use swc_ecma_transforms_typescript as typescript; diff --git a/crates/swc_ecmascript/Cargo.toml b/crates/swc_ecmascript/Cargo.toml index 93a259f0fe8..3b04f90d746 100644 --- a/crates/swc_ecmascript/Cargo.toml +++ b/crates/swc_ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.88.1" +version = "0.88.2" [package.metadata.docs.rs] all-features = true diff --git a/crates/swc_ecmascript/src/lib.rs b/crates/swc_ecmascript/src/lib.rs index 37dd2538ebd..b67c60bfa69 100644 --- a/crates/swc_ecmascript/src/lib.rs +++ b/crates/swc_ecmascript/src/lib.rs @@ -1,17 +1,27 @@ +#![cfg_attr(docsrs, feature(doc_cfg))] + pub use swc_ecma_ast as ast; #[cfg(feature = "codegen")] +#[cfg_attr(docsrs, doc(cfg(feature = "codegen")))] pub use swc_ecma_codegen as codegen; #[cfg(feature = "dep_graph")] +#[cfg_attr(docsrs, doc(cfg(feature = "dep_graph")))] pub use swc_ecma_dep_graph as dep_graph; #[cfg(feature = "minifier")] +#[cfg_attr(docsrs, doc(cfg(feature = "minifier")))] pub use swc_ecma_minifier as minifier; #[cfg(feature = "parser")] +#[cfg_attr(docsrs, doc(cfg(feature = "parser")))] pub use swc_ecma_parser as parser; #[cfg(feature = "preset_env")] +#[cfg_attr(docsrs, doc(cfg(feature = "preset_env")))] pub use swc_ecma_preset_env as preset_env; #[cfg(feature = "transforms")] +#[cfg_attr(docsrs, doc(cfg(feature = "transforms")))] pub use swc_ecma_transforms as transforms; #[cfg(feature = "utils")] +#[cfg_attr(docsrs, doc(cfg(feature = "utils")))] pub use swc_ecma_utils as utils; #[cfg(feature = "visit")] +#[cfg_attr(docsrs, doc(cfg(feature = "visit")))] pub use swc_ecma_visit as visit;