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

✨feature: add doc #1986

Merged
merged 16 commits into from
Mar 6, 2024
Merged

✨feature: add doc #1986

merged 16 commits into from
Mar 6, 2024

Conversation

jasonandjay
Copy link
Member

Add bitcoinjs-lib documentation

  • Automatically read ts file and generate
  • Automatically triggered by github actions (github pages need to be enabled)

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@junderw
Copy link
Member

junderw commented Sep 29, 2023

TODO:

  • Figure out why deploy-doc is broken.
  • Add more comments to various items in the library so that the docs are more fleshed out.

@jasonandjay
Copy link
Member Author

TODO:

  • Figure out why deploy-doc is broken.
  • Add more comments to various items in the library so that the docs are more fleshed out.

I guess it may caused by get pages token failed.
You can enable github pages first and select source from github actions, then you can re-run failed job.

@junderw
Copy link
Member

junderw commented Sep 30, 2023

Still not working.

This is the yaml file it recommended me when I tried to configure a static HTML setup through Github Actions.

Perhaps something is missing from your diff? Could you look into it for me?

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["master"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Single deploy job since we're just deploying
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v2
        with:
          # Upload entire repository
          path: '.'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v2

@junderw
Copy link
Member

junderw commented Sep 30, 2023

Looks like actions/configure-pages is missing?

@jasonandjay
Copy link
Member Author

Looks like actions/configure-pages is missing?

logger report [Branch "doc" is not allowed to deploy to github-pages due to environment protection rules.]
To allow the "doc" branch to deploy to GitHub Pages, you'll need to adjust the branch protection rules. Follow these steps:

Go to your GitHub Repository:
Open the repository in your browser.

Click on "Settings":
It's usually located near the right end of the menu bar, next to "Actions" and "Insights".

Navigate to "Branches":
In the left sidebar, click on the "Branches" tab.

Select "Add rule":
You should see an option to add a new branch protection rule. Click on it.

Enter "doc" as the branch name:
In the "Branch name pattern" field, type "doc" to specify the branch you want to adjust the rules for.

Configure Protection Rules:
Here, you'll have several options. You'll want to pay attention to the following:

Require pull request reviews before merging: If you have this enabled, make sure it allows merging without approval. You might need to disable it temporarily for the "doc" branch.

Require status checks to pass before merging: Ensure that the necessary checks (e.g., GitHub Pages deployment) are not required for the "doc" branch.

Include administrators: Make sure this option is checked if you want administrators to be exempt from these rules.

Save Changes:
After making the necessary adjustments, click on the "Save changes" button.

@junderw
Copy link
Member

junderw commented Sep 30, 2023

Ok, well, I can verify the results of the doc command locally. Perhaps we should make the doc jobs only run on master.

Having it run on pull requests will just pollute the CI with failed tests.

@jasonandjay
Copy link
Member Author

Deploy doc task has updated, it will only take effect on master branch.

@junderw
Copy link
Member

junderw commented Oct 2, 2023

I wonder about versioning.

If it would be possible to have it recognize whether it's being deployed on master or a tag and change the URL path?

Then maybe people could navigate to older versions by clicking a link to the docs generated for a specific tag.

I would hope that the default page is the last tagged version or something.

If that's not possible, I guess it's fine.

I'd also like to flesh out some of the documentation in this PR so that the first release of the docs isn't so bare bones.

If you can help by documenting any of the smaller stuff I'd appreciate it. The more the better.

@jasonandjay
Copy link
Member Author

I think add version control is possible and necessary but with low priority.
And flesh out documentation is how priority.
I want to add description and examples to function、class、interface and namespace.
examples can be copied from tests, so users can easy to use and it`s better for us to maintain.

such as fromBase58Check, do you think any other content or content style do we need to add?
demo

@jasonandjay
Copy link
Member Author

For properties, we can add description like this, do you think its ok?
proper

@junderw
Copy link
Member

junderw commented Oct 5, 2023

I want to add description and examples to function、class、interface and namespace. examples can be copied from tests, so users can easy to use and it`s better for us to maintain.

such as fromBase58Check, do you think any other content or content style do we need to add?

This looks fine. I am a little worried about tests and their copy-pasted doc-equivalents going stale... but I think as long as I remember to mention fixing the doc strings in review it should be fine.

I think add version control is possible and necessary but with low priority.

Yeah, this is a "nice to have"

You are awesome, thanks for your help!

package.json Outdated
@@ -54,6 +54,7 @@
"bech32": "^2.0.0",
"bip174": "^2.1.1",
"bs58check": "^3.0.1",
"typedoc-plugin-bitcoinjs-runcase": "^1.0.1",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a devDependency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it should me. I remember this but maybe something is wrong!!

I want to tell you about another thing.
I added an executable environment to the document to help us more flexibly display related cases and provide user testing.
The background is as follows

  1. We have a lot of test cases. Moving too many cases will affect the organizational structure of our code, and the workload will be huge.
  2. For related cases, single testing can be combined with the context to understand more, more comprehensively and more efficiently.

To achieve this goal, I did the following things, which also cost me a lot of time:

  1. Build bitcoinjs-lib browser version
  2. Develop typedoc-plugin-bitcoinjs-runcase plug-in to support sneaking into the executable environment
  3. Modify relevant comment tags

You can view the relevant effects here: https://jasonandjay.github.io/bitcoinjs-lib/functions/address.fromBase58Check.html

1
2

I think this is a great feature, but I need your help evaluating whether it's suitable

Copy link
Member Author

Choose a reason for hiding this comment

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

That way we can tell the user to test here and find more cases in the single test

Then we only need to give a correct usage method in example (I customized a @case tag), so that the construction efficiency of our document will be much higher

Copy link
Member Author

Choose a reason for hiding this comment

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

@junderw please take a look

Copy link

Choose a reason for hiding this comment

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

@jasonandjay typedoc-plugin-bitcoinjs-runcase is a production dependency and has react and react-dom as dependencies. That doesn't belong in bitcoinjs at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pajasevi yes, i will change it later, i want to know is this the right direction to add an executable environment to the document to simplify the case in the single test? so as to proceed with the next step.

Copy link
Member

Choose a reason for hiding this comment

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

This will take a while to review.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be in a follow up pr

Copy link
Member Author

Choose a reason for hiding this comment

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

Review typedoc plugin or comments in our repository?

Copy link
Member

Choose a reason for hiding this comment

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

Adding typedoc-plugin-bitcoinjs-runcase should be in a separate PR is what I'm saying.

@jasonandjay
Copy link
Member Author

Got it
typedoc-plugin-bitcoinjs-runcase is a devDependencies, so it will not intrude into our program and help provide a run code environment when building documents.

It will now be more efficient for us to improve the documentation

Or, let’s add the key comments in the document first, and then add the run case. What do you think?

Copy link

@Muniru0 Muniru0 left a comment

Choose a reason for hiding this comment

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

Amazing work.

@jasonandjay
Copy link
Member Author

I did two things

  1. ⏪ rollback: separate typedoc-plugin-bitcoinjs-runcase to another PR
  2. Add key comments to the code to make the document look more complete.

@junderw
Copy link
Member

junderw commented Mar 1, 2024

Thanks. That lowers the scope of the review significantly. I'll take another look later today.

@jasonandjay
Copy link
Member Author

Is there anything that needs to be optimized? Maybe we can push document construction to next step.

Copy link
Member

@junderw junderw left a comment

Choose a reason for hiding this comment

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

LGTM. Great job. Github is being weird. Crossing finger that this works lol.

@junderw junderw merged commit 894ad02 into bitcoinjs:master Mar 6, 2024
12 checks passed
@junderw
Copy link
Member

junderw commented Mar 6, 2024

Deployed successfully!

https://bitcoinjs.github.io/bitcoinjs-lib/

Maybe add this to the README?

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