Skip to content

Commit

Permalink
Add docgen support for attributes (e.g., #[view]) (Issue #7932) (#8636)
Browse files Browse the repository at this point in the history
* Fix aptos-labs/aptos-core#7932

Docgen should output attributes (#7932).

Output attributes (e.g., #[view] or #[resource_group(scope = global)])
from docgen for move code.  Currently only handles attibutes on
Function, Script/Module, and Struct/Resource.

Note that attributes are allowed on some other syntactic objects
(address scope, use statement, const definition, spec), but how to
format these usefully in docgen is unclear.  for these in docgen is
unclear.

Also fix an unrelated bug discovered when adapting
attribute_placement.move as a test of docgen: previously, only a
single Module/Script per input file would be output in docgen.

* Update move library docs with new docgen.

---------

Co-authored-by: Brian R. Murphy <brianrmurphy@gmail.com>
GitOrigin-RevId: bea5520c277d8e57982798a36c6b60c5aa8bee00
  • Loading branch information
2 people authored and aptos-bot committed Oct 23, 2024
1 parent f197daf commit c3d929b
Show file tree
Hide file tree
Showing 31 changed files with 428 additions and 214 deletions.
33 changes: 22 additions & 11 deletions aptos-framework/doc/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ is returned. This way, the caller of this function can publish additional resour



<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_exists_at">exists_at</a>(addr: <b>address</b>): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_exists_at">exists_at</a>(addr: <b>address</b>): bool
</code></pre>


Expand All @@ -960,7 +961,8 @@ is returned. This way, the caller of this function can publish additional resour



<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_guid_next_creation_num">get_guid_next_creation_num</a>(addr: <b>address</b>): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_guid_next_creation_num">get_guid_next_creation_num</a>(addr: <b>address</b>): u64
</code></pre>


Expand All @@ -984,7 +986,8 @@ is returned. This way, the caller of this function can publish additional resour



<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_sequence_number">get_sequence_number</a>(addr: <b>address</b>): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_sequence_number">get_sequence_number</a>(addr: <b>address</b>): u64
</code></pre>


Expand Down Expand Up @@ -1039,7 +1042,8 @@ is returned. This way, the caller of this function can publish additional resour



<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_authentication_key">get_authentication_key</a>(addr: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_authentication_key">get_authentication_key</a>(addr: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
</code></pre>


Expand Down Expand Up @@ -1425,7 +1429,8 @@ to the account owner's signer capability).
Returns true if the account at <code>account_addr</code> has a signer capability offer.


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_is_signer_capability_offered">is_signer_capability_offered</a>(account_addr: <b>address</b>): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_is_signer_capability_offered">is_signer_capability_offered</a>(account_addr: <b>address</b>): bool
</code></pre>


Expand All @@ -1451,7 +1456,8 @@ Returns true if the account at <code>account_addr</code> has a signer capability
Returns the address of the account that has a signer capability offer from the account at <code>account_addr</code>.


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_signer_capability_offer_for">get_signer_capability_offer_for</a>(account_addr: <b>address</b>): <b>address</b>
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_signer_capability_offer_for">get_signer_capability_offer_for</a>(account_addr: <b>address</b>): <b>address</b>
</code></pre>


Expand Down Expand Up @@ -2076,7 +2082,8 @@ The Account does not exist under the new address before creating the account.
### Function `get_guid_next_creation_num`


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_guid_next_creation_num">get_guid_next_creation_num</a>(addr: <b>address</b>): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_guid_next_creation_num">get_guid_next_creation_num</a>(addr: <b>address</b>): u64
</code></pre>


Expand All @@ -2093,7 +2100,8 @@ The Account does not exist under the new address before creating the account.
### Function `get_sequence_number`


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_sequence_number">get_sequence_number</a>(addr: <b>address</b>): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_sequence_number">get_sequence_number</a>(addr: <b>address</b>): u64
</code></pre>


Expand Down Expand Up @@ -2133,7 +2141,8 @@ The sequence_number of the Account is up to MAX_U64.
### Function `get_authentication_key`


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_authentication_key">get_authentication_key</a>(addr: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_authentication_key">get_authentication_key</a>(addr: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;
</code></pre>


Expand Down Expand Up @@ -2427,7 +2436,8 @@ The authentication scheme is ED25519_SCHEME and MULTI_ED25519_SCHEME.
### Function `is_signer_capability_offered`


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_is_signer_capability_offered">is_signer_capability_offered</a>(account_addr: <b>address</b>): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_is_signer_capability_offered">is_signer_capability_offered</a>(account_addr: <b>address</b>): bool
</code></pre>


Expand All @@ -2443,7 +2453,8 @@ The authentication scheme is ED25519_SCHEME and MULTI_ED25519_SCHEME.
### Function `get_signer_capability_offer_for`


<pre><code><b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_signer_capability_offer_for">get_signer_capability_offer_for</a>(account_addr: <b>address</b>): <b>address</b>
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="account.md#0x1_account_get_signer_capability_offer_for">get_signer_capability_offer_for</a>(account_addr: <b>address</b>): <b>address</b>
</code></pre>


Expand Down
6 changes: 4 additions & 2 deletions aptos-framework/doc/aptos_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ receive.
By default, this returns true if an account has not explicitly set whether the can receive direct transfers.


<pre><code><b>public</b> <b>fun</b> <a href="aptos_account.md#0x1_aptos_account_can_receive_direct_coin_transfers">can_receive_direct_coin_transfers</a>(<a href="account.md#0x1_account">account</a>: <b>address</b>): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_account.md#0x1_aptos_account_can_receive_direct_coin_transfers">can_receive_direct_coin_transfers</a>(<a href="account.md#0x1_account">account</a>: <b>address</b>): bool
</code></pre>


Expand Down Expand Up @@ -813,7 +814,8 @@ Check if the AptosCoin under the address existed.
### Function `can_receive_direct_coin_transfers`


<pre><code><b>public</b> <b>fun</b> <a href="aptos_account.md#0x1_aptos_account_can_receive_direct_coin_transfers">can_receive_direct_coin_transfers</a>(<a href="account.md#0x1_account">account</a>: <b>address</b>): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_account.md#0x1_aptos_account_can_receive_direct_coin_transfers">can_receive_direct_coin_transfers</a>(<a href="account.md#0x1_account">account</a>: <b>address</b>): bool
</code></pre>


Expand Down
24 changes: 16 additions & 8 deletions aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ AptosGovernance.



<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_voting_duration_secs">get_voting_duration_secs</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_voting_duration_secs">get_voting_duration_secs</a>(): u64
</code></pre>


Expand All @@ -731,7 +732,8 @@ AptosGovernance.



<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_min_voting_threshold">get_min_voting_threshold</a>(): u128
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_min_voting_threshold">get_min_voting_threshold</a>(): u128
</code></pre>


Expand All @@ -755,7 +757,8 @@ AptosGovernance.



<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_required_proposer_stake">get_required_proposer_stake</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_required_proposer_stake">get_required_proposer_stake</a>(): u64
</code></pre>


Expand Down Expand Up @@ -1289,7 +1292,8 @@ Return a signer for making changes to 0x1 as part of on-chain governance proposa



<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_initialize_for_verification">initialize_for_verification</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
<pre><code>#[verify_only]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_initialize_for_verification">initialize_for_verification</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
</code></pre>


Expand Down Expand Up @@ -1432,7 +1436,8 @@ Address @aptos_framework must exist GovernanceConfig and GovernanceEvents.
### Function `get_voting_duration_secs`


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_voting_duration_secs">get_voting_duration_secs</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_voting_duration_secs">get_voting_duration_secs</a>(): u64
</code></pre>


Expand All @@ -1448,7 +1453,8 @@ Address @aptos_framework must exist GovernanceConfig and GovernanceEvents.
### Function `get_min_voting_threshold`


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_min_voting_threshold">get_min_voting_threshold</a>(): u128
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_min_voting_threshold">get_min_voting_threshold</a>(): u128
</code></pre>


Expand All @@ -1464,7 +1470,8 @@ Address @aptos_framework must exist GovernanceConfig and GovernanceEvents.
### Function `get_required_proposer_stake`


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_required_proposer_stake">get_required_proposer_stake</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_required_proposer_stake">get_required_proposer_stake</a>(): u64
</code></pre>


Expand Down Expand Up @@ -1993,7 +2000,8 @@ pool_address must exist in StakePool.
### Function `initialize_for_verification`


<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_initialize_for_verification">initialize_for_verification</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
<pre><code>#[verify_only]
<b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_initialize_for_verification">initialize_for_verification</a>(aptos_framework: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, min_voting_threshold: u128, required_proposer_stake: u64, voting_duration_secs: u64)
</code></pre>


Expand Down
12 changes: 8 additions & 4 deletions aptos-framework/doc/block.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ Can only be called as part of the Aptos governance proposal process established
Return epoch interval in seconds.


<pre><code><b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_epoch_interval_secs">get_epoch_interval_secs</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_epoch_interval_secs">get_epoch_interval_secs</a>(): u64
</code></pre>


Expand Down Expand Up @@ -425,7 +426,8 @@ The runtime always runs this before executing the transactions in a block.
Get the current block height


<pre><code><b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_current_block_height">get_current_block_height</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_current_block_height">get_current_block_height</a>(): u64
</code></pre>


Expand Down Expand Up @@ -667,7 +669,8 @@ The BlockResource existed under the @aptos_framework.
### Function `get_epoch_interval_secs`


<pre><code><b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_epoch_interval_secs">get_epoch_interval_secs</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_epoch_interval_secs">get_epoch_interval_secs</a>(): u64
</code></pre>


Expand Down Expand Up @@ -710,7 +713,8 @@ The BlockResource existed under the @aptos_framework.
### Function `get_current_block_height`


<pre><code><b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_current_block_height">get_current_block_height</a>(): u64
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="block.md#0x1_block_get_current_block_height">get_current_block_height</a>(): u64
</code></pre>


Expand Down
6 changes: 4 additions & 2 deletions aptos-framework/doc/chain_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Publish the chain ID <code>id</code> of this instance under the SystemAddresses
Return the chain ID of this instance.


<pre><code><b>public</b> <b>fun</b> <a href="chain_id.md#0x1_chain_id_get">get</a>(): u8
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="chain_id.md#0x1_chain_id_get">get</a>(): u8
</code></pre>


Expand Down Expand Up @@ -135,7 +136,8 @@ Return the chain ID of this instance.
### Function `get`


<pre><code><b>public</b> <b>fun</b> <a href="chain_id.md#0x1_chain_id_get">get</a>(): u8
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="chain_id.md#0x1_chain_id_get">get</a>(): u8
</code></pre>


Expand Down
6 changes: 4 additions & 2 deletions aptos-framework/doc/chain_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ Marks that genesis has finished.
Helper function to determine if Aptos is in genesis state.


<pre><code><b>public</b> <b>fun</b> <a href="chain_status.md#0x1_chain_status_is_genesis">is_genesis</a>(): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="chain_status.md#0x1_chain_status_is_genesis">is_genesis</a>(): bool
</code></pre>


Expand All @@ -141,7 +142,8 @@ the same as <code>!<a href="chain_status.md#0x1_chain_status_is_genesis">is_gene
Testing <code><a href="chain_status.md#0x1_chain_status_is_operating">is_operating</a>()</code> is more frequent than <code><a href="chain_status.md#0x1_chain_status_is_genesis">is_genesis</a>()</code>.


<pre><code><b>public</b> <b>fun</b> <a href="chain_status.md#0x1_chain_status_is_operating">is_operating</a>(): bool
<pre><code>#[view]
<b>public</b> <b>fun</b> <a href="chain_status.md#0x1_chain_status_is_operating">is_operating</a>(): bool
</code></pre>


Expand Down
Loading

0 comments on commit c3d929b

Please sign in to comment.