bitcoinjs-lib icon indicating copy to clipboard operation
bitcoinjs-lib copied to clipboard

build api document

Open jasonandjay opened this issue 1 year ago • 4 comments

How about build a api document for easy use, maybe i can offer help

jasonandjay avatar Sep 26 '23 07:09 jasonandjay

PRs are open.

I would like to discuss the method / place where the documentation will live etc.

  1. Maintainability of the documentation (If we change the API how easy is it to update the documentation? Automatic is best)
  2. Ease of access (Can we deploy it in CI to Github Pages etc. to make it accessible to everyone with Github access?)

I think that something along the lines of in-line JSDoc style documenting and having some tool that auto-generates the documentation from those JSDocs.

Also, idk if TS/JS has anything like this, but in Rust you can run examples in the documentation during testing... if we could set up a CI job that somehow makes sure all example code in the documentation still works, that would be great.

junderw avatar Sep 26 '23 07:09 junderw

PRs are open.

I would like to discuss the method / place where the documentation will live etc.

  1. Maintainability of the documentation (If we change the API how easy is it to update the documentation? Automatic is best)
  2. Ease of access (Can we deploy it in CI to Github Pages etc. to make it accessible to everyone with Github access?)

I think that something along the lines of in-line JSDoc style documenting and having some tool that auto-generates the documentation from those JSDocs.

Also, idk if TS/JS has anything like this, but in Rust you can run examples in the documentation during testing... if we could set up a CI job that somehow makes sure all example code in the documentation still works, that would be great.

I think its a good way to gene doc by typedoc and typedoc-plugin-markdown, you can visit this https://jasonandjay.github.io/bitcoinjs-lib/ but i have some work to improve document readability, such as add sidebar

jasonandjay avatar Sep 29 '23 06:09 jasonandjay

We shouldn't be generating docs for private members and private methods.

A side bar would probably look better too.

Afterwards, we can figure out how to auto-generate it from this repo using Github Actions.

Then it would just be a lot of writing to make the documents more in-depth.

junderw avatar Sep 29 '23 07:09 junderw

We shouldn't be generating docs for private members and private methods.

A side bar would probably look better too.

Afterwards, we can figure out how to auto-generate it from this repo using Github Actions.

Then it would just be a lot of writing to make the documents more in-depth.

  • [x] private members has been removed
  • [x] sidebar has been added
  • [x] github actions has been added I have submitted PR and wait for your review Let`s focus our comments to improve api document

jasonandjay avatar Sep 29 '23 09:09 jasonandjay

I think this is done, isn't it?

junderw avatar Mar 14 '24 04:03 junderw

We have completed the documentation, but I'm aiming to enhance the user experience further. For instance, I'd like to integrate run cases directly under each function, allowing developers to test these cases within the document itself.

To keep our discussions focused, I initially created a separate PR for this. However, considering the relevance of this topic, I've closed and reopened this issue to centralize our conversation. 😂

Feel free to explore this implementation in the documentation: https://jasonandjay.github.io/bitcoinjs-lib/functions/address.fromBase58Check.html

To enable run cases in the documentation, I've:

  1. Compiled a browser-compatible version of bitcoinjs-lib for use in the documentation.
  2. Developed the typedoc-plugin-bitcoinjs-runcase to facilitate run cases.

However, there are some challenges to address:

The bitcoinjs-lib is primarily a Node.js library and typically requires webpack or similar tools for browser-side integration. This necessitates the need to either accommodate the Buffer object or find an alternative solution suitable for browser usage.

I'd love to hear your thoughts and any plans you might have on this.

While I don't see this as an immediate priority, it would be great to discuss potential approaches while moving on to other tasks.

jasonandjay avatar Mar 14 '24 07:03 jasonandjay

This necessitates the need to either accommodate the Buffer object or find an alternative solution suitable for browser usage.

This is something that I've been meaning to do for quite a while but Buffer is so intertwined in the whole BitcoinJS ecosystem that pulling it out is such a huge task...

I created a little library to try and add on some tools that will make moving from Buffer to UInt8Array. https://github.com/bitcoinjs/uint8array-tools

I was planning on going through each repo, cleaning out the Buffer references, then adding functions to uint8array-tools as I go along (if I need them).

But I've had less time to work on BitcoinJS stuff in the past couple years due to family issues and on and off work stuff.

junderw avatar Mar 14 '24 07:03 junderw

This necessitates the need to either accommodate the Buffer object or find an alternative solution suitable for browser usage.

This is something that I've been meaning to do for quite a while but Buffer is so intertwined in the whole BitcoinJS ecosystem that pulling it out is such a huge task...

I created a little library to try and add on some tools that will make moving from Buffer to UInt8Array. https://github.com/bitcoinjs/uint8array-tools

I was planning on going through each repo, cleaning out the Buffer references, then adding functions to uint8array-tools as I go along (if I need them).

But I've had less time to work on BitcoinJS stuff in the past couple years due to family issues and on and off work stuff.

That's indeed a valuable idea. However, the volume of work required is significant. I'm committed to identifying a viable solution, although it may require a considerable amount of time. Rest assured, I will keep you informed about any developments. Once the issue is resolved, I'll proceed with the integration of the run case. Thank you for your effort.

jasonandjay avatar Mar 14 '24 07:03 jasonandjay