From 6dcf82e5d6dfdab220eb0ea920d6aa5ca24567cf Mon Sep 17 00:00:00 2001 From: ncave <777696+ncave@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:06:56 -0800 Subject: [PATCH] [Rust] Add support for module comments --- src/Fable.AST/CHANGELOG.md | 4 ++++ src/Fable.AST/Fable.fs | 1 + src/Fable.Cli/CHANGELOG.md | 1 + src/Fable.Compiler/CHANGELOG.md | 1 + src/Fable.Transforms/FSharp2Fable.fs | 1 + src/Fable.Transforms/Rust/Fable2Rust.fs | 2 +- 6 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Fable.AST/CHANGELOG.md b/src/Fable.AST/CHANGELOG.md index 9e77fe7ed..844c59e16 100644 --- a/src/Fable.AST/CHANGELOG.md +++ b/src/Fable.AST/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +* [All] Add support for module comments (by @ncave) + ## 4.6.0 - 2025-01-28 * Stable release diff --git a/src/Fable.AST/Fable.fs b/src/Fable.AST/Fable.fs index 0836d4abf..332342dcf 100644 --- a/src/Fable.AST/Fable.fs +++ b/src/Fable.AST/Fable.fs @@ -441,6 +441,7 @@ type ModuleDecl = Name: string Entity: EntityRef Members: Declaration list + XmlDoc: string option } and Declaration = diff --git a/src/Fable.Cli/CHANGELOG.md b/src/Fable.Cli/CHANGELOG.md index d12d06acb..2687df236 100644 --- a/src/Fable.Cli/CHANGELOG.md +++ b/src/Fable.Cli/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * [Python] - Print root module and module function comments (by @alfonsogarciacaro) +* [Rust] Add support for module comments (by @ncave) * [Rust] Add support for null strings (by @ncave) ## 5.0.0-alpha.9 - 2025-01-28 diff --git a/src/Fable.Compiler/CHANGELOG.md b/src/Fable.Compiler/CHANGELOG.md index 280808a7a..7d036799f 100644 --- a/src/Fable.Compiler/CHANGELOG.md +++ b/src/Fable.Compiler/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * [Python] - Print root module and module function comments (by @alfonsogarciacaro) +* [Rust] Add support for module comments (by @ncave) * [Rust] Add support for null strings (by @ncave) ## 5.0.0-alpha.9 - 2025-01-28 diff --git a/src/Fable.Transforms/FSharp2Fable.fs b/src/Fable.Transforms/FSharp2Fable.fs index 1035075af..4cf8eec40 100644 --- a/src/Fable.Transforms/FSharp2Fable.fs +++ b/src/Fable.Transforms/FSharp2Fable.fs @@ -2080,6 +2080,7 @@ let rec private transformDeclarations (com: FableCompiler) ctx fsDecls = Name = fsEnt.CompiledName Entity = entRef Members = members + XmlDoc = tryGetXmlDoc fsEnt.XmlDoc } ] | sub -> transformDeclarations com ctx sub diff --git a/src/Fable.Transforms/Rust/Fable2Rust.fs b/src/Fable.Transforms/Rust/Fable2Rust.fs index f57b55f72..79a6e6b33 100644 --- a/src/Fable.Transforms/Rust/Fable2Rust.fs +++ b/src/Fable.Transforms/Rust/Fable2Rust.fs @@ -5095,7 +5095,7 @@ module Util = com.ClearAllImports(ctx) useItem :: importItems - let outerAttrs = transformAttributes com ctx ent.Attributes None + let outerAttrs = transformAttributes com ctx ent.Attributes decl.XmlDoc let innerAttrs = getInnerAttributes com ctx decl.Members let attrs = innerAttrs @ outerAttrs let modDecls = useDecls @ memberDecls