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

Add API doc generation #12

Merged
merged 12 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* [Constants](reference/interbit/constants.md)
* [configSelectors](reference/interbit/configSelectors.md)
* [createChains()](reference/interbit/createChains.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

Per your question in standup, it looks like we have an error in this API documentation. createChains is not actually a function, but is an object containing two functions: createChainsFromManifest and createChainsFromConfig(deprecated).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we shake the API tree, issues can sometimes fall out. 😄 I'll file an issue for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

* [createChainsFromManifest()](reference/interbit/createChainsFromManifest.adoc)
* [deploy()](reference/interbit/deploy.md)
* [manifestSelectors](reference/interbit/manifestSelectors.md)
* [startInterbit()](reference/interbit/startInterbit.md)
Expand All @@ -57,7 +58,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)
Copy link
Contributor

Choose a reason for hiding this comment

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

These function names are not clear when they do not contain the additional scope of the exported object tree. Is there some way we could include the property path from module exports in the documentation for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may be reading the source incorrectly, but it looks to me like the top-level exports for interbit-covenant-tools includes validate(). So the documentation hierarchy matches exactly. Are you looking for some sort of breadcrumb, so that when you're viewing validate() you can see that it's a top-level function?

As an aside, the validate() function's source comments are lacking an @returns, and may need review for accuracy.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are correct, I had thought this was one of validateManifest or validateConfig but it is not. I forgot that export was in interbit-covenant-tools. Thanks!

* [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
24 changes: 24 additions & 0 deletions api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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
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
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)/"
}
}
27 changes: 17 additions & 10 deletions make.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
#!/bin/bash

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

Choose a reason for hiding this comment

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

👍 colours!


# 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..."
echo -e "\033[34mPerforming post-build cleanup...\033[0m"
cd _book
rm Gemfile Gemfile.lock Makefile make.sh Rakefile
rm -f npm-debug.log package.json package-lock.json
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
rm -rf vendor _interbit apiadoc
else
echo "*** Looks like the doc build failed!"
echo -e "\033[1m\033[31m*** Looks like the doc build failed!\033[0m"
fi

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",
Copy link
Contributor

Choose a reason for hiding this comment

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

🔮 🌔

"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" %}
3 changes: 3 additions & 0 deletions reference/interbit/createChainsFromManifest.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= createChainsFromManifest()

{% include "/apiadoc/interbit/createChainsFromManifest.adoc" %}