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

Problem: Missing cpp library documents for developers #354

Merged
merged 14 commits into from
May 12, 2022

Conversation

damoncro
Copy link
Collaborator

@damoncro damoncro commented Apr 26, 2022

Close:

Solutions:

  • Add Erc20 doc comments examples
  • Add testnet tests
  • Add Doxygen, Sphinx, GitBook, mdbook supports
  • Generate the cpp documents with nix
  • Add github action docs.yml

@damoncro damoncro marked this pull request as draft April 26, 2022 09:45
@damoncro damoncro force-pushed the feat/cpp_documents_for_developers branch 2 times, most recently from ac85418 to e1e6a34 Compare May 3, 2022 04:03
@damoncro
Copy link
Collaborator Author

damoncro commented May 4, 2022

Added PR on cxx dtolnay/cxx#1048

@damoncro damoncro force-pushed the feat/cpp_documents_for_developers branch from a2e3699 to b15378b Compare May 5, 2022 10:51
@damoncro damoncro marked this pull request as ready for review May 5, 2022 10:51
@damoncro
Copy link
Collaborator Author

damoncro commented May 5, 2022

About gitbook, some problems on the graceful package, solution is here:

https://stackoverflow.com/questions/64211386/gitbook-cli-install-error-typeerror-cb-apply-is-not-a-function-inside-graceful

@damoncro
Copy link
Collaborator Author

damoncro commented May 5, 2022

Besides, https://github.com/matusnovak/doxybook2/ does not support mdbook, so mdbook may have some minor issues (some functions name are not clickable). May need some times to tweak.

So far, the work flow: rust -> c++ -> doxygen -> doxybook2 -> gitbook is the best, although gitbook is deprecated.

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

ok to merge, we'll see if the patch to cxx is accepted

@@ -19,6 +19,11 @@ tokio = { version = "1", features = ["rt"] }
[build-dependencies]
cxx-build = "1"

# TODO Wait until https://github.com/dtolnay/cxx/pull/1048 is merged or similar solution is found
cxx-build-with-doxygen = { git = "https://github.com/damoncro/cxx.git", rev = "42b011184b6d5a593cd7513edb1d554e0f086a0f", package = "cxx-build", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cxx-build-with-doxygen = { git = "https://github.com/damoncro/cxx.git", rev = "42b011184b6d5a593cd7513edb1d554e0f086a0f", package = "cxx-build", optional = true }
cxx-build-with-doxygen = { git = "https://github.com/crypto-com/cxx.git", rev = "42b011184b6d5a593cd7513edb1d554e0f086a0f", package = "cxx-build", optional = true }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 4 to 11
#[cfg(not(feature = "doxygen"))]
cxx_build::bridges(BRIDGES)
.flag_if_supported("-std=c++11")
.compile("defi_wallet_core");

#[cfg(feature = "doxygen")]
cxx_build_with_doxygen::bridges(BRIDGES)
.flag_if_supported("-std=c++11")
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be feature-guarded here? is there a situation here why one wouldn't want the build to be with doxygen-style comments? even for the headers, I guess IDEs may display them better if with Doxygen-style comments?

Copy link
Collaborator Author

@damoncro damoncro May 10, 2022

Choose a reason for hiding this comment

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

Now, it is still a workaround, enabling doxygen feature in Windows CI build will fail.

See https://github.com/crypto-com/defi-wallet-core-rs/runs/6304031148?check_suite_focus=true

So for the document generation, generate it when necessary.

Copy link
Contributor

@tomtau tomtau May 10, 2022

Choose a reason for hiding this comment

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

ok, maybe the comment can be added to explain... and perhaps instead of a feature, guard it by the target platform (windows / not-windows)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me fix the windows ci... I found it was not difficult.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -18,6 +18,14 @@ fn new_erc20(contract_address: String, web3api_url: String, chain_id: u64) -> ff
}
impl ffi::Erc20 {
/// Returns the decimal amount of tokens owned by `account_address`.
/// # Examples
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if there's this functionality similar to rustdoc in doxygen... but are the examples compiled to ensure that they are not out of date? (just like with rustdoc)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let me double check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Follow in #394

# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.

PROJECT_LOGO =
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't read all the config options, but I guess these can later be tweaked by Leslie or others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most configures are not relevant, doxygen only provides the xml files to further generating markdown files. Lesile should tweak the configures in the final gitbook markdown files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After discussed in the gamefi weekly meeting, we should upload the markdowns to a new repository and then git sync to gitbook platform.

Further adjustments would be made in markdowns.

Follow up in #396

## Doxygen
### Installation

brew install doxygen
Copy link
Contributor

Choose a reason for hiding this comment

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

the build instructions here may not be reproducible... so perhaps good to mention the minimum versions to use or provide a Nix environment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, let me setup it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@damoncro damoncro force-pushed the feat/cpp_documents_for_developers branch 2 times, most recently from 75c2d46 to 9011fce Compare May 10, 2022 03:24
@damoncro damoncro force-pushed the feat/cpp_documents_for_developers branch from 2c283f2 to fd6a2d7 Compare May 11, 2022 05:23
@damoncro
Copy link
Collaborator Author

Outstanding issue: #395

Copy link
Collaborator

@leejw51crypto leejw51crypto left a comment

Choose a reason for hiding this comment

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

lgtm

@tomtau tomtau merged commit d883192 into main May 12, 2022
@tomtau tomtau deleted the feat/cpp_documents_for_developers branch May 12, 2022 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants