-
Notifications
You must be signed in to change notification settings - Fork 128
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
Docs/predicate documentation #469
Conversation
WalkthroughThis pull request introduces significant enhancements to the documentation generation process, including new templates and scripts for generating markdown documentation for commands and predicates. It also includes updates to function signatures and comments in the codebase, improving clarity and readability. The changes are spread across various files, including GitHub workflows, Makefile, Go scripts, and several Go source files. Changes
TipsChat with CodeRabbit Bot (
|
144c5ab
to
1cf4340
Compare
8e18421
to
f5e0df8
Compare
f5e0df8
to
2b70390
Compare
2b70390
to
b8f2af4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files ignored due to filter (7)
- go.mod
- go.sum
- x/logic/migrations/v2/types/genesis.pb.go
- x/logic/migrations/v2/types/params.pb.go
- x/logic/migrations/v2/types/query.pb.go
- x/logic/migrations/v2/types/tx.pb.go
- x/logic/migrations/v2/types/types.pb.go
Files selected for processing (28)
- .github/workflows/lint.yml (1 hunks)
- .github/workflows/update-draft-docs.yml (1 hunks)
- Makefile (3 hunks)
- docs/command/okp4d_tx_gov_submit-legacy-proposal_software-upgrade.md (1 hunks)
- docs/predicate/predicates.md (1 hunks)
- scripts/generate_command_doc.go (1 hunks)
- scripts/generate_predicates_doc.go (1 hunks)
- scripts/main.go (1 hunks)
- scripts/templates/doc.gotxt (1 hunks)
- scripts/templates/func.gotxt (1 hunks)
- scripts/templates/list.gotxt (1 hunks)
- scripts/templates/package.gotxt (1 hunks)
- scripts/templates/text.gotxt (1 hunks)
- starship/tests/setup_test.go (1 hunks)
- starship/tests/suite.go (1 hunks)
- x/logic/predicate/address.go (1 hunks)
- x/logic/predicate/bank.go (3 hunks)
- x/logic/predicate/block.go (2 hunks)
- x/logic/predicate/chain.go (1 hunks)
- x/logic/predicate/crypto.go (2 hunks)
- x/logic/predicate/did.go (1 hunks)
- x/logic/predicate/file.go (2 hunks)
- x/logic/predicate/json.go (1 hunks)
- x/logic/predicate/string.go (1 hunks)
- x/logic/predicate/uri.go (1 hunks)
- x/logic/testutil/expected_keepers_mocks.go (1 hunks)
- x/mint/testutil/expected_keepers_mocks.go (1 hunks)
- x/vesting/testutil/expected_keepers_mocks.go (1 hunks)
Files skipped from review due to trivial changes (20)
- docs/command/okp4d_tx_gov_submit-legacy-proposal_software-upgrade.md
- docs/predicate/predicates.md
- scripts/generate_predicates_doc.go
- scripts/templates/doc.gotxt
- scripts/templates/func.gotxt
- scripts/templates/list.gotxt
- scripts/templates/package.gotxt
- scripts/templates/text.gotxt
- starship/tests/setup_test.go
- starship/tests/suite.go
- x/logic/predicate/address.go
- x/logic/predicate/bank.go
- x/logic/predicate/block.go
- x/logic/predicate/chain.go
- x/logic/predicate/json.go
- x/logic/predicate/string.go
- x/logic/predicate/uri.go
- x/logic/testutil/expected_keepers_mocks.go
- x/mint/testutil/expected_keepers_mocks.go
- x/vesting/testutil/expected_keepers_mocks.go
Additional comments: 17
x/logic/predicate/did.go (1)
- 19-37: The updated comments provide a more detailed explanation of the
DIDComponents
function, its parameters, and its usage. The changes include specifying the type ofDID
as an Atom and providing more detailed descriptions of theComponents
term and its constituents. The examples have been updated to reflect these changes. The changes improve the clarity and completeness of the documentation..github/workflows/lint.yml (2)
211-213: The new step added to the workflow for generating predicate documentation seems to be in line with the existing structure and practices. However, ensure that the
make doc-predicate
command is correctly defined in the Makefile and it generates the expected documentation.214-214: The check for Git diff in generated files has been moved down after the new step for generating predicate documentation. This is a good practice as it ensures that any changes made by the new step are also included in the Git diff check.
scripts/main.go (4)
1-10: The import statements are well organized and only necessary packages are imported. The
cobra
package is used for creating powerful modern CLI applications, andserver
fromcosmos-sdk
is used for handling server errors. Good use of packages for the intended functionality.12-34: The
main
function is well structured. It creates a root command with two subcommands for generating command and predicate documentation. Error handling is done properly, with specific exit codes forserver.ErrorCode
errors and a default exit code for other errors.36-45: The
generateCommandDocumentationCommand
function creates acobra.Command
for generating command documentation. It uses theGenerateCommandDocumentation
function to perform the actual generation. This is a good example of separation of concerns.47-56: The
generatePredicateDocumentationCommand
function creates acobra.Command
for generating predicate documentation. It uses theGeneratePredicateDocumentation
function to perform the actual generation. This is a good example of separation of concerns.x/logic/predicate/file.go (2)
13-22: The documentation for the
SourceFile
function has been enhanced with a more detailed explanation of the function's purpose, signature, and usage. The changes are clear and provide a better understanding of the function's role and how to use it.90-107: The documentation for the
Open
function has been significantly improved. The new comments provide a detailed explanation of the function's purpose, signature, and usage. The changes are clear and provide a better understanding of the function's role and how to use it.x/logic/predicate/crypto.go (2)
15-29: The updated comments for the
SHAHash
function provide a more detailed explanation of the function's purpose, usage, and limitations. The changes are primarily cosmetic and do not affect the function's implementation or behavior. The changes improve the readability and understandability of the code.46-59: The updated comments for the
HexBytes
function provide a more detailed explanation of the function's purpose and usage. The changes are primarily cosmetic and do not affect the function's implementation or behavior. The changes improve the readability and understandability of the code.scripts/generate_command_doc.go (1)
- 11-25: The function
GenerateCommandDocumentation
has been refactored from the previousmain
function andgenerateDocumentation
function. The error handling and logging that was previously in themain
function is now expected to be handled by the caller ofGenerateCommandDocumentation
. Ensure that the caller is properly handling any errors returned by this function..github/workflows/update-draft-docs.yml (1)
- 47-63: The new hunk introduces a step to update the predicates documentation repository. It uses the
fjogeleit/http-request-action
action to send an HTTP POST request to the GitHub API. The request is made to the URLhttps://api.github.com/repos/okp4/docs/actions/workflows/39152549/dispatches
and includes a custom header with an authorization token. The request payload is a JSON object containing various inputs such as the repository, section, docs directory, and draft status. This step is responsible for updating the predicates documentation repository. Ensure that the workflow in the predicates documentation repository is set up to handle these requests correctly. Also, verify that theOKP4_TOKEN
secret is set up in the GitHub secrets for this repository.Makefile (4)
353-353: The
doc
target in the Makefile has been updated to includedoc-predicate
in addition todoc-proto
anddoc-command
. This means that when thedoc
target is run, it will now also generate documentation for the predicates in the logic module. Ensure that this is the intended behavior and that the necessary resources for generating predicate documentation are available.384-387: The
doc-command
target has been updated. The script to generate the command documentation is now run from the root directory instead of thedocs
directory. Also, the script is now run with the argumentcommand
. Ensure that the script can be run from the root directory and that it correctly handles thecommand
argument.- @cd docs; \ - go run ../scripts/generate_command_doc.go; \ + @OUT_FOLDER="docs/command"; \ + go get ./scripts; \ + go run ./scripts/. command; \
- 396-396: The
doc-command
target now specifies a configuration file formarkdownlint
. Ensure that this file exists and contains the correct configuration for linting the generated command documentation.- ${DOCKER_IMAGE_MARKDOWNLINT} -f $$OUT_FOLDER + ${DOCKER_IMAGE_MARKDOWNLINT} -f $$OUT_FOLDER -c docs/.markdownlint.yaml
- 398-410: A new
doc-predicate
target has been added to the Makefile. This target generates markdown documentation for all the predicates in the logic module. It creates a new directorydocs/predicate
, runs a script to generate the documentation, and then lints the generated documentation usingmarkdownlint
. Ensure that the script correctly generates the predicate documentation and that themarkdownlint
configuration file is suitable for linting this documentation.+ .PHONY: doc-predicate + doc-predicate: ## Generate markdown documentation for all the predicates (module logic) + @echo "${COLOR_CYAN} 📖 Generate markdown documentation for the predicates${COLOR_RESET}" + @OUT_FOLDER="docs/predicate"; \ + rm -rf $$OUT_FOLDER; \ + mkdir -p $$OUT_FOLDER; \ + go get ./scripts; \ + go run ./scripts/. predicate; \ + docker run --rm \ + -v `pwd`:/usr/src/docs \ + -w /usr/src/docs \ + ${DOCKER_IMAGE_MARKDOWNLINT} -f $$OUT_FOLDER -c docs/.markdownlint.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thx 🙏
This PR addresses the generation of the documentation related to the prolog predicates implemented in the logic module.
Summary by CodeRabbit
Bech32Address
,BlockHeight
,BlockTime
,ChainID
,SHAHash
,HexBytes
,did_components/2
,Open
,JSONProlog
,ReadString
, andURIEncoded
functions for better clarity and understanding.