* docs: Relates to #193. Generate Methods in API docs to Substrate Interfaces Extrinsics and Storage from Metadata * Steps to generate Gitbook: ``` yarn run build:methodsdoc; yarn run build; yarn gitbook serve; ``` * Allows generating a docs/METHODS_STORAGE.md and docs/METHODS_EXTRINSICS.md files by running `yarn run build:methodsdoc` * Note: The script runs `node packages/types/src/MetadataMdWrapper.js`, which uses Babel.js to transpile the TypeScript file MetadataMd.ts into JavaScript as MetadataMd.js by using the babel-plugin-module-resolver dependency that has been added to package.json. It runs MetadataMd.js, which parses a hard-coded copy of a Metadata response from the Substrate Node, and then generates the two aforementioned Markdown files to be included in the Gitbook. * Important Note: DO NOT run `./node_modules/.bin/tsc packages/types/src/MetadataMd.ts; node packages/types/src/MetadataMd.js;`, as doing so may incorrectly transpile other TypeScript files, and will give errors like `TypeError: bn_js_1.default is not a constructor` when you run your unit tests. * Added links that work when you go to http://localhost:4000/api/ and click the "api" link on the side menu * Note: This was achieved by first adding the links in packages/api/README.md (i.e. `[Extrinsics (Substrate Interface)](../METHODS_EXTRINSICS.md)`). Note that the links could also be `METHODS_EXTRINSICS.html` and it would still work. It is VERY important to add links to these Markdown files in docs/SUMMARY.md (i.e. `[Storage](METHODS_STORAGE.md)`), as Gitbook generates HTML files in the same docs/ directory (i.e. it generates docs/METHODS_STORAGE.html) for any links provided in that file, and when you run `yarn run build; yarn gitbook serve` it will put a copy of those HTML files in the _book directory so it can be accessed in the browser. * Replaces PR #249 and #255 from jg-meta-md from jg-meta-md-luke branches * feat: Add script to generate decoded JSON file of the Metadata. Remove test. * Summary: * Running `yarn run build:decodedjson` will generate packages/types/src/Metadata.decoded.json from the Metadata in the Metadata.rpc.ts file. * docs: Manually add RPC Substrate Interface API docs including author, chain, state, system * docs: Append Storage Substrate methods to Storage Methods. Add consistent styling. Add descriptions * Add Description at top of Substrate Interface page for RPC, Extrinsics, and Storage in API docs * Add styling to Substrate Interface page for Extrinsics and Storage, including: * ▸ symbol before each method * bold method names * adding Summary label and only showing the summary label if a summary exists * adding a horizonal line between each section of methods * Fix by adding new line after description when there is one in Extrinscis and Storage * Manually creating a markdown file containing storage.substrate methods METHODS_STORAGE_SUBSTRATE.md, and then reading from the file and appending it to the bottom of the METHODS_STORAGE.md file that is generated, since the storage.substrate methods are not available from the Metadata. * Fix by reading and writing to file using UTF8 instead of ASCII so symbols appear correctly * Updating docs/METHODS_RPC.md and adding a horizontal line before the first section of methods * docs: Fix Readme file step numbering * docs: Generate the Substrate Interface Markdown files first when run yarn run build * refactor: Move babel register config into shared file * refactor: Use shared function to overcome codeclimate error * fix: Reword description of RPC methodsto address review comment * docs: Rename to Runtime Node Interfaces to address review comment * docs: Rename to Runtime Node Interface in api Readme to address review comment * docs: Fix minor typos * docs: Fixes #117 providing Readme ref to jsonrpc docs * fix: Remove preceding whitespace * docs: Rename so RPC is not referred to as an interface of the runtime * docs: Refer to Storage Substrate methods as always available to runtime implementation * test: Restore the test that was unnecessary deleted * Move scripts into packages/types/src/scripts * docs: Add script to generate RPC interface docs * fix: Fix TSlint error where element had any time due to no index signature * refactor: Restore code back to normal instead of bowing to codeclimate whims * refactor: Declare meaningful variables to make more readable * docs: Show .subscribe when it is isSubscription method
49 lines
3.3 KiB
Markdown
49 lines
3.3 KiB
Markdown
[](https://polkadot.js.org)
|
|

|
|
[](https://github.com/Flet/semistandard)
|
|
[](https://www.npmjs.com/package/@polkadot/api)
|
|
[](https://travis-ci.org/polkadot-js/api)
|
|
[](https://codeclimate.com/github/polkadot-js/api/maintainability)
|
|
[](https://coveralls.io/github/polkadot-js/api?branch=master)
|
|
[](https://greenkeeper.io/)
|
|
[](https://david-dm.org/polkadot-js/api)
|
|
[](https://david-dm.org/polkadot-js/api#info=devDependencies)
|
|
|
|
# @polkadot/api
|
|
|
|
This library provides a clean wrapper around all the methods exposed by a Polkadot/Subtrate network client. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
|
|
|
|
## overview
|
|
|
|
The API is split up into a number of internal packages -
|
|
|
|
- [@polkadot/api](packages/api/) The low-level base API library
|
|
- [@polkadot/api-codec](packages/api-codec/) Codecs for all Polkadot primitives
|
|
- [@polkadot/api-rx](packages/api-rx/) A RxJs Observable wrapper around the API
|
|
- [@polkadot/api-provider](packages/api-provider/) Providers for connecting
|
|
|
|
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
|
|
|
- [@polkadot/extrinsics](packages/type-extrinsics/) Base extrinsic definitions & codecs
|
|
- [@polkadot/jsonrpc](packages/type-jsonrpc/) Definitions for JSONRPC endpoints
|
|
- [@polkadot/storage](packages/type-storage/) Definitions for storage entries
|
|
|
|
## development
|
|
|
|
Contributions are welcome!
|
|
|
|
To start off, this repo (along with others in the [@polkadot](https://github.com/polkadot-js/) family) uses yarn workspaces to organise the code. As such, after cloning dependencies _should_ be installed via `yarn`, not via npm, the latter will result in broken dependencies.
|
|
|
|
To get started -
|
|
|
|
1. Clone the repo locally, via `git clone https://github.com/polkadot-js/api <optional local path>`
|
|
2. Ensure that you have a recent version of Node.js, for development purposes [Node 10](https://nodejs.org/en/) is recommended.
|
|
3. Ensure that you have a recent version of Yarn, for development purposes [Yarn >=1.3.2](https://yarnpkg.com/docs/install) is required.
|
|
4. Install the dependencies by running `yarn`
|
|
5. Build the API Docs, via `yarn run build`
|
|
6. Ready! Now you can launch the API Docs, via `yarn gitbook serve`
|
|
7. Access the API Docs via [http://localhost:4000](http://localhost:4000)
|
|
|
|
## tutorials
|
|
|
|
Looking for tutorials to get started? Look at [examples](https://polkadot.js.org/api/examples/) for guides on how to use the API. |