-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move] Fixes for enums in Move model + add support in docgen (#18907)
## Description Fixes some issues with enums in Move model creation, and adds support for enums in docgen, and adding doc comments to enum variants. ## Test plan Added a test for docgen with enums -- this tests both the bugfixes and also the generation of doc comments for enums. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
Showing
11 changed files
with
573 additions
and
33 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
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
18 changes: 18 additions & 0 deletions
18
external-crates/move/crates/move-docgen/tests/sources/enums_test.move
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,18 @@ | ||
/// This is a doc comment above an annotation. | ||
#[allow(unused_const)] | ||
module 0x42::m { | ||
/// This is a doc comment above an enum | ||
public enum Enum { | ||
/// This is a doc comment above a variant | ||
A, | ||
B(), | ||
C(u64), | ||
/// Another doc comment | ||
D { | ||
/// Doc text on variant field | ||
x: u64 | ||
}, | ||
E { x: u64, y: u64 }, | ||
} | ||
} | ||
|
106 changes: 106 additions & 0 deletions
106
external-crates/move/crates/move-docgen/tests/sources/enums_test.spec_inline.md
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,106 @@ | ||
|
||
<a name="0x42_m"></a> | ||
|
||
# Module `0x42::m` | ||
|
||
This is a doc comment above an annotation. | ||
|
||
|
||
- [Enum `Enum`](#0x42_m_Enum) | ||
|
||
|
||
<pre><code></code></pre> | ||
|
||
|
||
|
||
<a name="0x42_m_Enum"></a> | ||
|
||
## Enum `Enum` | ||
|
||
This is a doc comment above an enum | ||
|
||
|
||
<pre><code><b>public</b> enum Enum | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Variants</summary> | ||
|
||
|
||
<dl> | ||
<dt> | ||
Variant <code>A</code> | ||
</dt> | ||
<dd> | ||
This is a doc comment above a variant | ||
</dd> | ||
<dt> | ||
Variant <code>B</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
<dt> | ||
Variant <code>C</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>pos0: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
<dt> | ||
Variant <code>D</code> | ||
</dt> | ||
<dd> | ||
Another doc comment | ||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>x: u64</code> | ||
</dt> | ||
<dd> | ||
Doc text on variant field | ||
</dd> | ||
</dl> | ||
|
||
<dt> | ||
Variant <code>E</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>x: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
|
||
<dl> | ||
<dt> | ||
<code>y: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
</dl> | ||
|
||
|
||
</details> |
102 changes: 102 additions & 0 deletions
102
...-crates/move/crates/move-docgen/tests/sources/enums_test.spec_inline_no_fold.md
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,102 @@ | ||
|
||
<a name="0x42_m"></a> | ||
|
||
# Module `0x42::m` | ||
|
||
This is a doc comment above an annotation. | ||
|
||
|
||
- [Enum `Enum`](#0x42_m_Enum) | ||
|
||
|
||
<pre><code></code></pre> | ||
|
||
|
||
|
||
<a name="0x42_m_Enum"></a> | ||
|
||
## Enum `Enum` | ||
|
||
This is a doc comment above an enum | ||
|
||
|
||
<pre><code><b>public</b> enum Enum | ||
</code></pre> | ||
|
||
|
||
|
||
##### Variants | ||
|
||
|
||
<dl> | ||
<dt> | ||
Variant <code>A</code> | ||
</dt> | ||
<dd> | ||
This is a doc comment above a variant | ||
</dd> | ||
<dt> | ||
Variant <code>B</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
<dt> | ||
Variant <code>C</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>pos0: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
<dt> | ||
Variant <code>D</code> | ||
</dt> | ||
<dd> | ||
Another doc comment | ||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>x: u64</code> | ||
</dt> | ||
<dd> | ||
Doc text on variant field | ||
</dd> | ||
</dl> | ||
|
||
<dt> | ||
Variant <code>E</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
|
||
<dl> | ||
<dt> | ||
<code>x: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
|
||
<dl> | ||
<dt> | ||
<code>y: u64</code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
</dl> |
Oops, something went wrong.