Skip to content

Commit

Permalink
Merge pull request #12 from interbit/ewan/add-api-parsing
Browse files Browse the repository at this point in the history
Add API doc generation
  • Loading branch information
btlewan committed Sep 4, 2018
2 parents e5b7ed5 + 2b2acca commit d985d2d
Show file tree
Hide file tree
Showing 67 changed files with 785 additions and 645 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
node_modules
lerna-debug.log
npm-debug.log
packages/*/node_modules
packages/*/npm-debug.log
_interbit
apiadoc
**/db-*
**/_book
**/build
**/.lock
**/dist
**/.DS_Store

# Vim ignores
[._]*.s[a-v][a-z]
Expand Down
54 changes: 47 additions & 7 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,51 @@
* [Permission Model](/architecture/permission_model.adoc)

* [Reference](reference/README.adoc)
* [interbit](reference/interbit/README.md)
* [interbit](reference/interbit/README.adoc)
* [Constants](reference/interbit/constants.md)
* [configSelectors](reference/interbit/configSelectors.md)
* [createChains()](reference/interbit/createChains.md)
* [deploy()](reference/interbit/deploy.md)
* [manifestSelectors](reference/interbit/manifestSelectors.md)
* [startInterbit()](reference/interbit/startInterbit.md)
* [validateConfig()](reference/interbit/validateConfig.md)
* [Configuration Selectors](reference/interbit/config-selectors/README.adoc)
* [getAdminValidators()](reference/interbit/config-selectors/getAdminValidators.adoc)
* [getApps()](reference/interbit/config-selectors/getApps.adoc)
* [getChains()](reference/interbit/config-selectors/getChains.adoc)
* [getChainByAlias()](reference/interbit/config-selectors/getChainByAlias.adoc)
* [getChainCovenant()](reference/interbit/config-selectors/getChainCovenant.adoc)
* [getChainJoins()](reference/interbit/config-selectors/getChainJoins.adoc)
* [getChainValidators()](reference/interbit/config-selectors/getChainValidators.adoc)
* [getJoinTypeForChain()](reference/interbit/config-selectors/getJoinTypeForChain.adoc)
* [getCovenants()](reference/interbit/config-selectors/getCovenants.adoc)
* [getPeers()](reference/interbit/config-selectors/getPeers.adoc)
* [joinTypes](reference/interbit/config-selectors/joinTypes.adoc)
* [configureChains()](reference/interbit/configureChains.adoc)
* [configureJoins()](reference/interbit/configureJoins.adoc)
* [connectToPeers()](reference/interbit/connectToPeers.adoc)
* [create()](reference/interbit/create.adoc)
* [createChains](reference/interbit/createChains/README.adoc)
* [createChainsFromConfig()](reference/interbit/createChains/createChainsFromConfig.adoc)
* [createChainsFromManifest()](reference/interbit/createChains/createChainsFromManifest.adoc)
* [deploy()](reference/interbit/deploy.adoc)
* [deployCovenants()](reference/interbit/deployCovenants.adoc)
* [generateDeploymentDetails()](reference/interbit/generateDeploymentDetails.adoc)
* [generateManifest()](reference/interbit/generateManifest.adoc)
* [getConfig()](reference/interbit/getConfig.adoc)
* [getManifest()](reference/interbit/getManifest.adoc)
* [joinChains()](reference/interbit/joinChains.adoc)
* [Manifest Selectors](reference/interbit/manifest-selectors/README.adoc)
* [getApps()](reference/interbit/manifest-selectors/getApps.adoc)
* [getBlockMasterByAlias()](reference/interbit/manifest-selectors/getBlockMasterByAlias.adoc)
* [getChainIdByAlias()](reference/interbit/manifest-selectors/getChainIdByAlias.adoc)
* [getChains()](reference/interbit/manifest-selectors/getChains.adoc)
* [getCovenantHashByAlias()](reference/interbit/manifest-selectors/getCovenantHashByAlias.adoc)
* [getCovenants()](reference/interbit/manifest-selectors/getCovenants.adoc)
* [getGenesisBlockByAlias()](reference/interbit/manifest-selectors/getGenesisBlockByAlias.adoc)
* [getGenesisBlocks()](reference/interbit/manifest-selectors/getGenesisBlocks.adoc)
* [getPeers()](reference/interbit/manifest-selectors/getPeers.adoc)
* [getRootChildren()](reference/interbit/manifest-selectors/getRootChildren.adoc)
* [packCovenants()](reference/interbit/packCovenants.adoc)
* [setRootChainManifest()](reference/interbit/setRootChainManifest.adoc)
* [start()](reference/interbit/start.adoc)
* [startInterbit()](reference/interbit/startInterbit.adoc)
* [updateIndexHtmls()](reference/interbit/updateIndexHtmls.adoc)
* [validateConfig()](reference/interbit/validateConfig.adoc)
* [interbit-cli](reference/interbit-cli/README.md)
* [build](reference/interbit-cli/build.md)
* [configuration file](reference/interbit-cli/config.adoc)
Expand All @@ -57,7 +94,10 @@
* [manifest file](reference/interbit-cli/manifest.adoc)
* [start](reference/interbit-cli/start.md)
* [interbit-covenant-tools](reference/interbit-covenant-tools/README.md)
* [validate()](reference/interbit-covenant-tools/validate.adoc)
* [interbit-ui-components](reference/interbit-ui-components/README.md)
* [formatDate()](reference/interbit-ui-components/formatDate.adoc)
* [formatDateTime()](reference/interbit-ui-components/formatDateTime.adoc)
* [interbit-ui-tools](reference/interbit-ui-tools/README.adoc)
* [actionCreators](reference/interbit-ui-tools/actionCreators.md)
* [actionTypes](reference/interbit-ui-tools/actionTypes.md)
Expand Down
25 changes: 25 additions & 0 deletions api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Capture source comments for select packages
APIDIR=_interbit/_API
rm -rf ${APIDIR}

PKGDIR=_interbit/packages
JSONDIR=${APIDIR}/json
ADOCDIR=apiadoc
rm -rf ${ADOCDIR}
mkdir -p ${JSONDIR}
mkdir ${ADOCDIR}

packages=(
'interbit'
'interbit-covenant-tools'
'interbit-platform-tools'
'interbit-ui-components'
'interbit-ui-tools'
)
for pkg in ${packages[@]}; do
echo "Processing package ${pkg}..."
jsdoc -r -X -c conf.jsdoc ${PKGDIR}/${pkg} > ${JSONDIR}/${pkg}.json
node_modules/gitbook-plugin-interbit/scripts/apijson2adoc.js -j ${JSONDIR}/${pkg}.json -d ${ADOCDIR} -p ${pkg}
done
13 changes: 13 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Post-build cleanup
if [ -d "_book" ]; then
echo -e "\033[34mPerforming post-build cleanup...\033[0m"
cd _book
rm Gemfile Gemfile.lock Makefile Rakefile make.sh api.sh cleanup.sh
rm -f npm-debug.log package.json package-lock.json conf.jsdoc
rm index.js local.js app.json README.md .gitignore
rm -rf vendor _interbit apiadoc
else
echo -e "\033[1m\033[31m*** Looks like the doc build failed!\033[0m"
fi
6 changes: 6 additions & 0 deletions conf.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source": {
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "/(build|dist|tests|node_modules)/"
}
}
4 changes: 2 additions & 2 deletions examples/initialize.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ Further Documentation:
- [deploy](../reference/interbit-cli/deploy.adoc)
- [interbit.config.js](../reference/interbit-cli/config.adoc)
- [interbit.manifest.json](../reference/interbit-cli/manifest.adoc)
- [deploy function](../reference/interbit/deploy.md)
- [createChains](../reference/interbit/createChains.md)
- [deploy function](../reference/interbit/deploy.adoc)
- [createChains](../reference/interbit/createChains/README.adoc)
30 changes: 14 additions & 16 deletions make.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
#!/bin/bash

echo 'Building documentation, please wait... '
echo -e "\033[34mBuilding documentation, please wait...\033[0m"

# Make sure Ruby dependencies installed
bundle install || echo "Ruby dependencies failed to install; make sure Bundler is installed!"
bundle install || echo -e "\033[31mRuby dependencies failed to install; make sure Bundler is installed!\033[0m"

# Make sure that `gitbook` command is installed
if ! [ -x "$(command -v gitbook)" ]; then
echo "Installing GitBook (and other node dependencies)..."
echo -e "\033[34mInstalling GitBook (and other node dependencies)...\033[0m"
npm i
fi

# Install GitBook plugins, themes, etc.
echo "Installing GitBook plugins, themes, etc..."
echo -e "\033[34mInstalling GitBook plugins, themes, etc...\033[0m"
gitbook install

# Capture source comments for select packages
echo -e "\033[34mCollecting API details...\033[0m"

rm -rf _interbit
git clone https://github.com/interbit/interbit.git _interbit
./api.sh

# Build the book's HTML
echo "Building the documentation..."
echo -e "\033[34mBuilding the documentation...\033[0m"
gitbook build

# Post-build cleanup
if [ -d "_book" ]; then
echo "Performing post-build cleanup..."
cd _book
rm Gemfile Gemfile.lock Makefile make.sh Rakefile
rm -f npm-debug.log package.json package-lock.json
rm index.js local.js app.json README.md .gitignore
rm -rf vendor
else
echo "*** Looks like the doc build failed!"
fi
./cleanup.sh

echo "Done!"
echo -e "\033[1m\033[34mDone!\033[0m"
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"gitbook-cli": "^2.3.2",
"express": "^4.16.3",
"jsdoc": "^3.5.5",
"heroku-ssl-redirect": "^0.0.4"
},
"repository": {
Expand All @@ -23,6 +24,8 @@
"start": "node index.js",
"build": "bash make.sh",
"test": "node node_modules/gitbook-plugin-interbit/scripts/doc_checks.js",
"spell": "node node_modules/gitbook-plugin-interbit/scripts/doc_checks.js -c spelling",
"includes": "node node_modules/gitbook-plugin-interbit/scripts/doc_checks.js -c includes",
"heroku-postbuild": "npm run build"
},
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions reference/interbit-covenant-tools/validate.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= validate

{% include "/apiadoc/interbit-covenant-tools/validate.adoc" %}
3 changes: 3 additions & 0 deletions reference/interbit-ui-components/formatDate.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= formatDate()

{% include "/apiadoc/interbit-ui-components/formatDate.adoc" %}
3 changes: 3 additions & 0 deletions reference/interbit-ui-components/formatDateTime.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= formatDateTime()

{% include "/apiadoc/interbit-ui-components/formatDateTime.adoc" %}
72 changes: 72 additions & 0 deletions reference/interbit/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
= Interbit

Interbit offers the same features as the `interbit-cli` but in small
functions requireable for programmatically managing your chains.

The `interbit` package contains functions to help you to:

- gather `interbit-cli` specific command line arguments
- start Interbit nodes
- create chains
- link:configureChains.adoc[configure chains]
- link:configureJoins.adoc[configure joins]
- manage covenants
- connect to peers
- and so much more!
Reference:

- link:/examples/initialize.md[An Example]
- link:https://github.com/interbit/interbit/blob/master/packages/interbit/src/index.js[The Exports]
- link:https://www.npmjs.com/package/interbit[The Package]
== Options

The main functions available in `interbit` all accept a uniform
`options` object that correspond to the CLI options used in the
link:../interbit-cli/README.md[`interbit-cli`] package.

Some options are not supported in every script and will be ignored. See
the specific script/cli reference for supported options.

[horizontal]
[.api.p]`keyPair` [.api.t]__Object__::
A keypair object to boot the hypervisor with.
+
--
[horizontal]
[.api.p]`publicKey` [.api.t]__String__::
The public key.

[.api.p]`privateKey` [.api.t]__String__::
The private key.
--

[.api.p]`location` [.api.t]__String__::
The working directory for this function/script.

[.api.p]`manifest` [.api.t]__Object__::
The contents of the loaded link:../interbit-cli/manifest.adoc[manifest]
file.

[.api.p]`config` [.api.t]__Object__::
The contents of the loaded link:../interbit-cli/config.adoc[config]
file.

[.api.p]`port` [.api.t]__Number__::
The port for Interbit to communicate on.

[.api.p]`dbPath` [.api.t]__String__::
The path to the database Interbit is using for this node.

[.api.p]`connect` [.api.t]__Boolean__::
Whether this node is simply connecting to other already running
instances, or should do the deployment configuration of joins/covenants
etc. itself.

[.api.p]`isWatchModeEnabled` [.api.t]__Boolean__ [.api.d]**Default=true**::
Whether watch mode is enabled. Defaults to true.

[.api.p]`isDevModeEnabled` [.api.t]__Boolean__::
Whether dev mode is enabled. Defaults to false.
55 changes: 0 additions & 55 deletions reference/interbit/README.md

This file was deleted.

21 changes: 21 additions & 0 deletions reference/interbit/config-selectors/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
= Configuration Selectors

A set of selectors for getting information from a properly formatted
configuration file.

== Functions available

- link:getAdminValidators.adoc[`getAdminValidators`]
- link:getApps.adoc[`getApps`]
- link:getChains.adoc[`getChains`]
- link:getChainByAlias.adoc[`getChainByAlias`]
- link:getChainCovenant.adoc[`getChainCovenant`]
- link:getChainJoins.adoc[`getChainJoins`]
- link:getChainValidators.adoc[`getChainValidators`]
- link:getJoinTypeForChain.adoc[`getJoinTypeForChain`]
- link:getCovenants.adoc[`getCovenants`]
- link:getPeers.adoc[`getPeers`]

== Objects available

- link:joinTypes.adoc[`joinTypes`]
15 changes: 15 additions & 0 deletions reference/interbit/config-selectors/getAdminValidators.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
= getAdminValidators()

== [.signature]__getAdminValidators(config)__

== Parameters

[horizontal]
[.api.p]`config` [.api.t]__Object__::
The configuration to select from.

== Returns

[horizontal]
[.api.t]__Object__::
The admin validator public keys.
Loading

0 comments on commit d985d2d

Please sign in to comment.