This repository was archived by the owner on Feb 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Autogen config docs #47
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ coverage | |
| # production | ||
| build | ||
|
|
||
| # documentation generation | ||
| docs/config.md | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| npm-debug.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
|
|
||
| const BufferList = require('bl'); | ||
|
|
||
| module.exports = { | ||
| preExampleConfig: new BufferList(` | ||
| --- | ||
| title: Configuring Parity Ethereum | ||
| --- | ||
|
|
||
| Parity can be configured using either the [CLI options](#cli-options) or a [config file](#config-file). Should the CLI flags and the config file disagree about a setting, the CLI takes precedence. | ||
|
|
||
| You can list all CLI options by running \`$parity --help\`. The vast majority of CLI options map to a setting in the TOML file, for example \`--mode-timeout 500\` can be set by creating a config file: | ||
|
|
||
| \`\`\`toml | ||
| [parity] | ||
| mode_timeout = 500 | ||
| \`\`\` | ||
|
|
||
| ## Config File | ||
|
|
||
| Parity can be configured using a [TOML](https://github.com/toml-lang/toml) file. The file can be generated using the [Parity Config Generator](https://paritytech.github.io/parity-config-generator/). To start parity with a config file, the file needs to be located in: | ||
|
|
||
| * Windows: \`%UserProfile%\\AppData\\Roaming\\Parity\\Ethereum\\config.toml\` | ||
| * Linux: \`~/.local/share/io.parity.ethereum/config.toml\` | ||
| * macOS: \`$HOME/Library/Application Support/io.parity.ethereum/config.toml\` | ||
|
|
||
| To use a custom path run \`$ parity --config path/to/config.toml\`. | ||
|
|
||
| ## Default config.toml | ||
|
|
||
| The following is a representation of a configuration file with all default values (*note: the \`[stratum]\` section is not present by default, and including it in your config currently enables stratum*). | ||
|
|
||
| \`\`\`toml`), | ||
| postExampleConfig: new BufferList('\n```\n'), | ||
| preConfigDoc: new BufferList(` | ||
| ## Presets | ||
|
|
||
| Parity can also be launched with a [preset configuration file](https://github.com/paritytech/parity-ethereum/tree/master/parity/cli/presets) using the \`--config\` flag with one of the following values: | ||
| * \`dev\`: uses [dev chain specifications](Private-development-chain) with [Instant-seal](Pluggable-Consensus#instant-seal) consensus engine. The gas price is set to 0. | ||
| * \`dev-insecure\`: uses the same configuration as \`dev\`, plus sets the flag \`no_consensus\`, allows all RPC APIs and accepts all RPC interfaces and hosts, as well as all IPFS hosts. | ||
| * \`insecure\`: uses the Mainnet default configuration, plus sets the flag \`no_consensus\`, allows all RPC APIs and accepts all RPC interfaces and hosts, as well as all IPFS hosts. | ||
| * \`mining\`: uses the Mainnet default configuration, plus increases the number of peers to min 50 and max 100, it disables the Dapps and IPC interface. It forces the sealing of blocks with a minimum of 4 seconds interval, forces the reseal for any new transaction (external or local), reduces the transaction queue size to 2048 while increasing the cache size to 256 MB and setting the \`trace\` logging level for the \`miner\` and \`own_tx\` modules. | ||
| * \`non-standard-ports\`: sets the client to listen to the port 30305 and 8645 for RPC connections. | ||
|
|
||
| ## Configuration options | ||
|
|
||
| `), | ||
| postConfigDoc: new BufferList(``) | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const BufferList = require('bl'); | ||
| const docTemplate = require('../docs/docTemplate.js'); | ||
| const data = require('./generate-config-data.js'); | ||
|
|
||
| const outputDir = '../docs/'; | ||
| const outputFile = 'config.md'; | ||
|
|
||
| function dirtySerialize (valueItem) { | ||
|
tomusdrw marked this conversation as resolved.
|
||
| if (typeof valueItem !== 'undefined') { | ||
| const rawDefaultValue = valueItem; | ||
| var defaultValue; | ||
| if (typeof rawDefaultValue === 'object') { | ||
| if (rawDefaultValue === null) { | ||
| defaultValue = 'null'; | ||
| } else { | ||
| defaultValue = JSON.stringify(rawDefaultValue); | ||
| } | ||
| } else { | ||
| if (rawDefaultValue === '') { | ||
| defaultValue = '""'; | ||
| } else { | ||
| defaultValue = rawDefaultValue; | ||
| } | ||
| } | ||
| return defaultValue; | ||
| } | ||
| } | ||
|
|
||
| function compiledToml (compiledData) { | ||
| var compiledBuffer = new BufferList(); | ||
| for (const key in compiledData) { | ||
| if (key[0] !== '_') { | ||
| const sectionValues = compiledData[key]; | ||
| compiledBuffer.append('[' + key + ']\n'); | ||
| for (const value in sectionValues) { | ||
| if (value.indexOf('section') < 0 && value.indexOf('description') < 0) { | ||
| const valueItem = sectionValues[value]['default']; | ||
| compiledBuffer.append(value + ' = ' + dirtySerialize(valueItem) + '\n'); | ||
| } | ||
| } | ||
| compiledBuffer.append('\n'); | ||
| } | ||
| } | ||
| return compiledBuffer; | ||
| } | ||
|
|
||
| // Command line options, configs, and descriptions. | ||
| function compiledMd (cliOptions) { | ||
| const compiledBuffer = new BufferList(); | ||
| const builtTree = {}; | ||
| for (const option in cliOptions) { | ||
| const configSection = cliOptions[option]['configSection']; | ||
| const configProp = cliOptions[option]['configProp']; | ||
| const helpText = cliOptions[option]['help']; | ||
| const variableName = cliOptions[option]['variableName']; | ||
| const defaultValue = dirtySerialize(cliOptions[option]['defaultValue']); | ||
| var cliName = variableName.replace(/_/g, '-').slice(4); | ||
| if (cliName[0] === '-') { | ||
| cliName = cliName.slice(1); | ||
| } | ||
| cliName = '--' + cliName; | ||
| const toAppend = BufferList('\n'); | ||
| toAppend.append('## ' + cliName.slice(2) + '\n'); | ||
| toAppend.append(helpText + '\n'); // description | ||
| toAppend.append('#### Command line option \n `' + cliName + '`\n'); // cli flag | ||
| if (typeof configSection !== 'undefined') { | ||
| toAppend.append('#### Config file option \n```toml\n' + '[' + configSection + ']' + '\n' + configProp + ' = ' + defaultValue + '\n```\n'); // config item | ||
| } | ||
| toAppend.append('#### Default Value \n`' + defaultValue + '`\n'); | ||
| if (typeof builtTree[configSection] !== 'undefined') { | ||
| builtTree[configSection].append(toAppend); | ||
| } else { | ||
| builtTree[configSection] = toAppend; | ||
| } | ||
| } | ||
| for (var section in builtTree) { | ||
| var sectionText = section; | ||
| if (section === 'undefined') { | ||
| sectionText = 'CLI Only'; | ||
| } | ||
| compiledBuffer.append('# ' + sectionText + '\n'); | ||
| compiledBuffer.append(builtTree[section]); | ||
| compiledBuffer.append('\n'); | ||
| } | ||
|
|
||
| return compiledBuffer; | ||
| } | ||
|
|
||
| async function buildPage () { | ||
| var compiledBuffer = new BufferList(); | ||
| const source = await data.fetchSource(); | ||
| compiledBuffer.append(docTemplate.preExampleConfig); | ||
| compiledBuffer.append(compiledToml(data.getData(source))); | ||
| compiledBuffer.append(docTemplate.postExampleConfig); | ||
| compiledBuffer.append(docTemplate.preConfigDoc); | ||
| compiledBuffer.append(compiledMd(data.getCliOptions(source))); | ||
| compiledBuffer.append(docTemplate.postConfigDoc); | ||
| return compiledBuffer; | ||
| } | ||
|
|
||
| (async function () { | ||
| fs.writeFileSync(path.resolve(__dirname, outputDir + outputFile), (await buildPage()).toString()); | ||
| })().catch(e => { | ||
| console.error(e); | ||
| process.exit(1); | ||
| }); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of storing this templates in a regular
.mdfiles (since you would get syntax highlighting) and then load them viapreExampleConfig: fs.readFileSync('./template/pre-example.md', 'utf8'). But this is good enough as well :)