Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
9f7ae2ee
Commit
9f7ae2ee
authored
4 months ago
by
bgallois
Committed by
Hugo Trentesaux
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add documentation
parent
7ccedac8
No related branches found
No related tags found
1 merge request
!313
Fix #283 generate documentation for storage and constants
Pipeline
#39808
waiting for manual action
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
xtask/src/gen_doc.rs
+39
-0
39 additions, 0 deletions
xtask/src/gen_doc.rs
with
39 additions
and
0 deletions
xtask/src/gen_doc.rs
+
39
−
0
View file @
9f7ae2ee
...
@@ -440,6 +440,24 @@ fn get_max_weight_from_metadata_v15(
...
@@ -440,6 +440,24 @@ fn get_max_weight_from_metadata_v15(
}
}
}
}
/// Converts a `Type<PortableForm>` into a human-readable string representation.
///
/// This function is a core part of the type resolution pipeline, working together with:
/// - `resolve_type()` to obtain type definitions.
/// - `format_generics()` to correctly format generic parameters.
///
/// It processes a `Type<PortableForm>` from the metadata registry and outputs a Rust-like string representation,
/// handling all supported type definitions (composite types, sequences, arrays, tuples, primitives, etc.).
///
/// # Returns
/// - `Ok(String)`: A formatted type string (e.g., `"Vec<u32>"`, `"(i32, bool)"`).
/// - `Err(anyhow::Error)`: If metadata are incorrect.
///
/// # How It Works With Other Functions:
/// - Calls `format_generics()` to handle generic type parameters.
/// - Calls `resolve_type()` when resolving inner types inside sequences, arrays, and tuples.
/// - Used by `resolve_type()` as a formatting step after retrieving a type.
///
fn
format_type
(
ty
:
&
Type
<
PortableForm
>
,
types
:
&
PortableRegistry
)
->
Result
<
String
>
{
fn
format_type
(
ty
:
&
Type
<
PortableForm
>
,
types
:
&
PortableRegistry
)
->
Result
<
String
>
{
let
path
=
ty
.path
.to_string
();
let
path
=
ty
.path
.to_string
();
...
@@ -477,6 +495,16 @@ fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> Result<Stri
...
@@ -477,6 +495,16 @@ fn format_type(ty: &Type<PortableForm>, types: &PortableRegistry) -> Result<Stri
}
}
}
}
/// Resolves a type ID to a formatted string representation.
///
/// This function serves as a bridge between raw type IDs and fully formatted types.
/// It works closely with `format_type()`, ensuring that once a type is found, it is properly formatted.
///
/// # How It Works With Other Functions:
/// - Retrieves a type from the registry using `types.resolve(type_id)`.
/// - If successful, calls `format_type()` to get a human-readable format.
/// - Used internally by `format_type()` when resolving type dependencies.
///
fn
resolve_type
(
type_id
:
u32
,
types
:
&
PortableRegistry
)
->
Result
<
String
>
{
fn
resolve_type
(
type_id
:
u32
,
types
:
&
PortableRegistry
)
->
Result
<
String
>
{
types
types
.resolve
(
type_id
)
.resolve
(
type_id
)
...
@@ -484,6 +512,16 @@ fn resolve_type(type_id: u32, types: &PortableRegistry) -> Result<String> {
...
@@ -484,6 +512,16 @@ fn resolve_type(type_id: u32, types: &PortableRegistry) -> Result<String> {
.unwrap_or_else
(||
bail!
(
"Invalid metadata"
))
.unwrap_or_else
(||
bail!
(
"Invalid metadata"
))
}
}
/// Formats generic type parameters into a Rust-like string representation.
///
/// This function helps `format_type()` handle generic types, ensuring that type parameters
/// are formatted correctly when they exist. If a type has generic parameters, they are enclosed
/// in angle brackets (e.g., `<T, U>`).
///
/// # How It Works With Other Functions:
/// - Called inside `format_type()` to process generic type parameters.
/// - Uses `resolve_type()` to retrieve and format each generic type.
///
fn
format_generics
(
fn
format_generics
(
params
:
&
[
scale_info
::
TypeParameter
<
PortableForm
>
],
params
:
&
[
scale_info
::
TypeParameter
<
PortableForm
>
],
types
:
&
PortableRegistry
,
types
:
&
PortableRegistry
,
...
@@ -501,6 +539,7 @@ fn format_generics(
...
@@ -501,6 +539,7 @@ fn format_generics(
Ok
(
format!
(
"<{}>"
,
generics
.join
(
", "
)))
Ok
(
format!
(
"<{}>"
,
generics
.join
(
", "
)))
}
}
}
}
fn
parse_storage_entry
(
fn
parse_storage_entry
(
variant
:
&
frame_metadata
::
v15
::
StorageEntryMetadata
<
scale_info
::
form
::
PortableForm
>
,
variant
:
&
frame_metadata
::
v15
::
StorageEntryMetadata
<
scale_info
::
form
::
PortableForm
>
,
types
:
&
PortableRegistry
,
types
:
&
PortableRegistry
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment