Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

RFC: generated API docs from typescript declarations #2548

Closed
alanshaw opened this issue Oct 17, 2019 · 8 comments
Closed

RFC: generated API docs from typescript declarations #2548

alanshaw opened this issue Oct 17, 2019 · 8 comments
Assignees
Labels

Comments

@alanshaw
Copy link
Member

alanshaw commented Oct 17, 2019

I had an idea in #651 (comment) that we could add typescript declarations (i.e. not convert the project to typescript just a type delcarations file types.d.ts with typings information) and generate our documentation from them. It would give us incentive to keep them up to date and make js-ipfs more friendly to our community of typescript users!

The docs would be decoupled from the actual code but we already have that problem.

Maybe use http://typedoc.org/?

@carsonfarmer might have some ideas if this is possible and might want to be the one to PR the declarations 😝

refs #1166
refs #2320

@alanshaw alanshaw added kind/support A question or request for support exploration labels Oct 17, 2019
@carsonfarmer
Copy link

This is very exciting to hear! I understand from @raulk that the libp2p team is similarly interested in adding declarations files to individual repos, which would likely make the efforts on js-ipfs much easier. I'm not sure what the timeline is for libp2p projects though?

We've used typedoc before (see https://textileio.github.io/js-textile-wallet/ for example) and quite liked it.

@hugomrdias
Copy link
Member

hugomrdias commented Oct 24, 2019

I have been trying to push this for a long time, nice to know we are open to this now.
ipfsd-ctl already has some typedefs and the next version will have a lot more this is what makes this ipfs-inactive/interface-js-ipfs-core#541 (comment) possible.

Happy to make this happen huge improvement to DX

@alanshaw
Copy link
Member Author

I'm somewhat disappointed with typedoc...

I added type definitions to abortable-iterator to try it out and was immediately burnt by TypeStrong/typedoc#1050:

Screenshot 2019-10-29 at 10 46 41

When the "Only Exported" checkbox is checked the list on the right is incorrect. Where's my sink, transorm and duplex exports? Source code:

Screenshot 2019-10-29 at 10 47 01

I also have a function called source and a type called Source. Clicking the links in the menu on the right do not work properly because it generates <a name="source" /> and <a name="Source" />.

For reference, my setup: alanshaw/abortable-iterator#2

@hugomrdias
Copy link
Member

hugomrdias commented Oct 30, 2019

Why do you export source as default again? i stopped using default exports a long time ago it only gives you problems esm or no esm. https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/

Below is a preview for the latest ipfsd-ctl api docs in markdown (still WIP)

Table of Contents

create

src/index.js:34-41

Create a Factory

Parameters

Returns FactoryDaemon

createNode

src/index.js:49-57

Create a node

Parameters

Returns Promise<Daemon>

createNodeTests

src/index.js:65-88

Create a node for tests

Parameters

Returns Promise<Daemon>

createTestsInterface

src/index.js:97-121

Create a interface for tests setup

Parameters

Returns TestsInterface

createServer

src/index.js:132-137

Create a Endpoint Server

Parameters

  • options (Object | number) Configuration options or just the port.
    • options.port number Port to start the server on.

Returns Server

TestsInterfaceCreateNode

src/index.js:139-145

Type: Function

Parameters

Returns Promise<Daemon> Returns a IPFSd-ctl Daemon

TestsInterfaceSetup

src/index.js:139-145

Type: Function

Parameters

Returns Promise<IpfsClient> Returns an IPFS core API

TestsInterfaceTeardown

src/index.js:139-145

Type: Function

Returns Promise<void>

TestsInterface

src/index.js:139-145

Type: object

Properties

IpfsOptions

src/index.js:139-145

Same as https://github.com/ipfs/js-ipfs/blob/master/README.md#ipfs-constructor

Type: Object

Properties

FactoryOptions

src/index.js:139-145

Type: Object

Properties

  • remote boolean? Use remote endpoint to spawn the nodes. Defaults to true when not in node.
  • port number? Remote endpoint port. (Defaults to 43134)
  • host string? Remote endpoint host. (Defaults to localhost)
  • secure string? Remote endpoint uses http or https. (Defaults to false)
  • defaultAddrs Boolean? Use the daemon default Swarm addrs.
  • disposable Boolean? A new repo is created and initialized for each invocation, as well as cleaned up automatically once the process exits.
  • type string? The daemon type, see below the options:- go - spawn go-ipfs daemon
    • js - spawn js-ipfs daemon
    • proc - spawn in-process js-ipfs instance
  • ipfsHttp Object? Setup IPFS HTTP client to be used by ctl.
    • ipfsHttp.ref Object? Reference to a IPFS HTTP Client object. (defaults to the local require(ipfs-http-client))
    • ipfsHttp.path string? Path to a IPFS HTTP Client to be required. (defaults to the local require.resolve('ipfs-http-client'))
  • ipfsApi Object? Setup IPFS API to be used by ctl.
    • ipfsApi.ref Object? Reference to a IPFS API object. (defaults to the local require(ipfs))
    • ipfsApi.path string? Path to a IPFS API implementation to be required. (defaults to the local require.resolve('ipfs'))
  • ipfsBin String? Path to a IPFS exectutable . (defaults to the local 'js-ipfs/src/bin/cli.js')
  • env Object? Additional environment variables, passed to executing shell. Only applies for Daemon controllers.
  • ipfsOptions IpfsOptions? Options for the IPFS instance
  • args Array? Custom cli args.

@hugomrdias
Copy link
Member

new iteration in html using typedoc and autogenerated type defs all from vanilla js with jsdoc
https://hugomrdias.keybase.pub/ipfsd-ctl-docs/

@NatoBoram
Copy link

Wouldn't it be just simpler to migrate everything to TypeScript? Since it's literally just JavaScript with types, you can convert the whole project without changing a thing at first and just add actual types gradually.

@bluelovers
Copy link
Contributor

where are the typescript file at? i didn't see it in this repo

@SgtPooki
Copy link
Member

js-ipfs is being deprecated in favor of Helia. You can learn more about this deprecation and read the migration guide.

Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see #4336).

This should be fixed in Helia since it's written in typescript. I believe libp2p is in the process of being updated to typescript as well.

@github-project-automation github-project-automation bot moved this from 🥞 Todo to ✅ Done in js-ipfs deprecation May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Status: Done
Development

No branches or pull requests

6 participants