From 5fb8d9214fd624aaaa4e09186ce513ae7848b9ae Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Thu, 19 Nov 2015 10:37:08 -0800 Subject: [PATCH] Add table of contents to docs --- README.md | 4 +++ docs/index.md | 61 +++++++++++++++++++++++++++++++++++++++++-- docs/src/index.md.ejs | 3 --- package.json | 3 +++ scripts/build_docs.js | 5 ++-- scripts/ci.sh | 5 +++- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5bf5bcf..f6abff83 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/d 2. `cd` into the repository and install dependencies with `npm install` 3. `npm test` or `npm test --coverage` (`istanbul` will create coverage reports in coverage/lcov-report/`) +##Generating Documentation + +The continuous integration tests require that the documentation stays up-to-date. If you make changes the the JSON schemas, fixtures, or documentation sources, you must update the documentation by running `npm run docgen`. + ##More Information + [Ripple Dev Portal](https://ripple.com/build/) diff --git a/docs/index.md b/docs/index.md index dabfb294..9a3be4d0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,62 @@ -RippleAPI Reference -------------------- + + +# RippleAPI Reference + +- [Introduction](#introduction) + - [Boilerplate](#boilerplate) +- [Basic Types](#basic-types) + - [Ripple Address](#ripple-address) + - [Account Sequence Number](#account-sequence-number) + - [Currency](#currency) + - [Value](#value) + - [Amount](#amount) +- [Transaction Overview](#transaction-overview) + - [Transaction Types](#transaction-types) + - [Transaction Flow](#transaction-flow) + - [Transaction Fees](#transaction-fees) + - [Transaction Instructions](#transaction-instructions) + - [Transaction ID](#transaction-id) +- [Transaction Specifications](#transaction-specifications) + - [Payment](#payment) + - [Trustline](#trustline) + - [Order](#order) + - [Order Cancellation](#order-cancellation) + - [Settings](#settings) + - [Suspended Payment Creation](#suspended-payment-creation) + - [Suspended Payment Cancellation](#suspended-payment-cancellation) + - [Suspended Payment Execution](#suspended-payment-execution) +- [API Methods](#api-methods) + - [connect](#connect) + - [disconnect](#disconnect) + - [isConnected](#isconnected) + - [getServerInfo](#getserverinfo) + - [getFee](#getfee) + - [getLedgerVersion](#getledgerversion) + - [getTransaction](#gettransaction) + - [getTransactions](#gettransactions) + - [getTrustlines](#gettrustlines) + - [getBalances](#getbalances) + - [getBalanceSheet](#getbalancesheet) + - [getPaths](#getpaths) + - [getOrders](#getorders) + - [getOrderbook](#getorderbook) + - [getSettings](#getsettings) + - [getAccountInfo](#getaccountinfo) + - [getLedger](#getledger) + - [preparePayment](#preparepayment) + - [prepareTrustline](#preparetrustline) + - [prepareOrder](#prepareorder) + - [prepareOrderCancellation](#prepareordercancellation) + - [prepareSettings](#preparesettings) + - [prepareSuspendedPaymentCreation](#preparesuspendedpaymentcreation) + - [prepareSuspendedPaymentCancellation](#preparesuspendedpaymentcancellation) + - [prepareSuspendedPaymentExecution](#preparesuspendedpaymentexecution) + - [sign](#sign) + - [submit](#submit) + - [generateAddress](#generateaddress) + - [computeLedgerHash](#computeledgerhash) + + # Introduction diff --git a/docs/src/index.md.ejs b/docs/src/index.md.ejs index 8caad9cf..6adc1879 100644 --- a/docs/src/index.md.ejs +++ b/docs/src/index.md.ejs @@ -1,6 +1,3 @@ -RippleAPI Reference -------------------- - <% include introduction.md.ejs %> <% include boilerplate.md.ejs %> <% include basictypes.md.ejs %> diff --git a/package.json b/package.json index 69be7169..c849c43d 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "babel-eslint": "^4.1.3", "babel-loader": "^5.3.2", "coveralls": "~2.10.0", + "doctoc": "^0.15.0", "ejs": "^2.3.4", "eslint": "^1.3.0", "eslint-plugin-flowtype": "^1.0.0", @@ -52,6 +53,8 @@ }, "scripts": { "build": "gulp", + "doctoc": "doctoc docs/index.md --title '# RippleAPI Reference' --github --maxlevel 2", + "docgen": "node --harmony scripts/build_docs.js", "clean": "rm -rf dist/npm && rm -rf build/flow", "typecheck": "babel --optional runtime --blacklist flow -d build/flow/ src/ && flow check", "compile": "babel -D --optional runtime -d dist/npm/ src/", diff --git a/scripts/build_docs.js b/scripts/build_docs.js index ab38aef1..137a1e33 100644 --- a/scripts/build_docs.js +++ b/scripts/build_docs.js @@ -1,6 +1,7 @@ 'use strict'; const fs = require('fs'); const path = require('path'); +const execSync = require('child_process').execSync; const ejs = require('ejs'); const renderFromPaths = require('json-schema-to-markdown-table').renderFromPaths; @@ -39,9 +40,9 @@ function main() { console.error(error); process.exit(1); } else { - const outputPath = process.argv.length > 2 ? process.argv[2] : - path.join(ROOT, 'docs', 'index.md'); + const outputPath = path.join(ROOT, 'docs', 'index.md'); fs.writeFileSync(outputPath, output); + execSync('npm run doctoc', {cwd: ROOT}); process.exit(0); } }); diff --git a/scripts/ci.sh b/scripts/ci.sh index ed009fe1..9c56696c 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -37,7 +37,10 @@ integrationtest() { } doctest() { - node --harmony scripts/build_docs.js docs/index.md.test + mv docs/index.md docs/index.md.save + npm run docgen + mv docs/index.md docs/index.md.test + mv docs/index.md.save docs/index.md cmp docs/index.md docs/index.md.test rm docs/index.md.test }