Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure constant getters show in docs #4649

Merged
merged 4 commits into from
Oct 4, 2023

Conversation

frangio
Copy link
Contributor

@frangio frangio commented Oct 4, 2023

The main example of what was missing can be seen in UPGRADE_INTERFACE_VERSION in UUPSUpgradeable.

@frangio frangio requested a review from a team October 4, 2023 00:12
@changeset-bot
Copy link

changeset-bot bot commented Oct 4, 2023

⚠️ No Changeset found

Latest commit: 89ce935

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

ernestognw
ernestognw previously approved these changes Oct 4, 2023
);
};

module.exports.returns2 = function ({ item }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not returnsExtended or similar? I don't think returns2 is really expressive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the short version, if you feel strongly about it we could use returnsExtended.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep returns2, don't want to block this

Comment on lines 42 to 46
module.exports.functions = function ({ item }) {
return [...findAll(['VariableDeclaration', 'FunctionDefinition'], item)].filter(f =>
f.nodeType === 'VariableDeclaration' ? f.visibility === 'public' : f.visibility !== 'private',
);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this should be updated in solidity-docgen, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's more complicated because of backwards compatibility. functions currently returns FunctionDefinition nodes and not VariableDeclaration nodes, so it might break some templates.

@frangio
Copy link
Contributor Author

frangio commented Oct 4, 2023

I moved getters to the end of the list of functions because they were showing up before the constructor.

@socket-security
Copy link

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@openzeppelin/docs-utils 0.1.4...0.1.5 None +0/-0 10.4 kB

Comment on lines +43 to +46
return [
...[...findAll('FunctionDefinition', item)].filter(f => f.visibility !== 'private'),
...[...findAll('VariableDeclaration', item)].filter(f => f.visibility === 'public'),
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works:

Suggested change
return [
...[...findAll('FunctionDefinition', item)].filter(f => f.visibility !== 'private'),
...[...findAll('VariableDeclaration', item)].filter(f => f.visibility === 'public'),
];
return [
...findAll('FunctionDefinition', item).filter(f => f.visibility !== 'private'),
...findAll('VariableDeclaration', item).filter(f => f.visibility === 'public'),
];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we can keep the constructor getters at first

Suggested change
return [
...[...findAll('FunctionDefinition', item)].filter(f => f.visibility !== 'private'),
...[...findAll('VariableDeclaration', item)].filter(f => f.visibility === 'public'),
];
const functionDefs = findAll('FunctionDefinition', item)
const constructor = functionDefs.find(f => f.kind == 'constructor');
return [
constructor,
...findAll('VariableDeclaration', item).filter(f => f.visibility === 'public'),
...functionDefs.filter(f => f.visibility !== 'private')
];

For cases like AccessManager and AccessControl I think it's valuable to have the ADMIN_ROLE/DEFAULT_ADMIN_ROLE definitions at first.

It's true that ADMIN_ROLE and PUBLIC_ROLE don't have NatSpec anyways, so I wouldn't have problems keeping the current code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works

It doesn't because findAll is a generator function, it doesn't return an array.

);
};

module.exports.returns2 = function ({ item }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep returns2, don't want to block this

@frangio frangio merged commit 39400b7 into OpenZeppelin:master Oct 4, 2023
13 checks passed
@frangio frangio deleted the fix-docs-getters branch October 4, 2023 15:54
frangio added a commit that referenced this pull request Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants