Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Autogen config docs#47

Merged
jam10o-new merged 4 commits into
masterfrom
autogen-config-docs
Dec 27, 2018
Merged

Autogen config docs#47
jam10o-new merged 4 commits into
masterfrom
autogen-config-docs

Conversation

@jam10o-new
Copy link
Copy Markdown
Contributor

@jam10o-new jam10o-new commented Dec 24, 2018

Somewhat "working", might not be the ideal format, but can change anything if needed.
part of: openethereum/parity-ethereum#10067

@jam10o-new jam10o-new changed the title [wip?] Autogen config docs Autogen config docs Dec 24, 2018
@axelchalon
Copy link
Copy Markdown
Contributor

Fine by me if it does the job! 👍
cc @tomusdrw

From an architecture POV it might make sense in the future to put generate-config-data.js (or the gist of it) in its own/separate repo. Then, we could use it as dependency in Parity Config Generator and have generate-config-doc.js be in the paritytech wiki repo and executed there, which would make more sense.

@jam10o-new
Copy link
Copy Markdown
Contributor Author

Should I merge this in that case, or do we still need to do reviews @axelchalon?

@axelchalon
Copy link
Copy Markdown
Contributor

I'd wait for Tomek to have a look

Copy link
Copy Markdown
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Seems pretty cool! I'd clean up the code a bit though and will be glad to merge.

Comment thread scripts/generate-config-docs.js Outdated

const output_dir = "./docs/"
const outpit_file = "config.md"
const pre_example_config = new BufferList("---\ntitle: Configuring Parity Ethereum\n---\n\nParity 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.\n\nYou 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:\n\n```toml\n[parity]\nmode_timeout = 500\n```\n\n## Config File\n\nParity 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:\n\n* Windows: `%UserProfile%\\AppData\\Roaming\\Parity\\Ethereum\\config.toml`\n* Linux: `~/.local/share/io.parity.ethereum/config.toml`\n* macOS: `$HOME/Library/Application Support/io.parity.ethereum/config.toml`\n\nTo use a custom path run `$ parity --config path/to/config.toml`.\n\n\n## Default config.toml\n\nThe 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*).\n```toml\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe use ` (backtick) and format the newlines properly? (although you would need to escape inline backticks).

I think it would be best to put this to a separate file and just fs.readFileSync from the template file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

made a separate file with all the template stuff but I'm not sure if it's what you were thinking of 😅

Comment thread scripts/generate-config-docs.js
Comment thread scripts/generate-config-data.js Outdated
Comment thread docs/config.md Outdated
use generate-config-data as a library, do not fetch twice
if running within the publish-docs script, should grab local mod.rs (not tested yet)
seperate docTemplate file (maybe not using templates properly)
linting and formatting
@jam10o-new
Copy link
Copy Markdown
Contributor Author

jam10o-new commented Dec 27, 2018

I need to test whether the change I made to generate-config-data (grab local mod.rs if it exists) actually works, but I'll ask y'all to look at this again if everything works properly.

edit: this doesn't seem to work yet :(

@jam10o-new
Copy link
Copy Markdown
Contributor Author

was not an issue on the js side- fixed in commit openethereum/parity-ethereum@169c30a

Copy link
Copy Markdown
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment thread scripts/generate-config-data.js Outdated
}));
});
} else {
resolve(fs.readFileSync(path.resolve(__dirname, '../../parity/cli/mod.rs'), 'UTF-8'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this:

const util = require('util');
...
function fetchSource() {
  if (process.env.AUTOGENSCRIPT) {
     return util.promisify(fs.readFile)(path.resolve(__dirname, '../../parity/cli/mod.rs'), 'UTF-8'));
  }
  
  return https.get(...)
     ....
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

readFile is already an async function, so it returns a promise 👍

Comment thread docs/docTemplate.js
const BufferList = require('bl');

module.exports = {
preExampleConfig: new BufferList(`
Copy link
Copy Markdown
Contributor

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 .md files (since you would get syntax highlighting) and then load them via preExampleConfig: fs.readFileSync('./template/pre-example.md', 'utf8'). But this is good enough as well :)

@jam10o-new jam10o-new merged commit b37144a into master Dec 27, 2018
@jam10o-new
Copy link
Copy Markdown
Contributor Author

jam10o-new commented Dec 27, 2018

ack - shouldn't have merged this before making sure it's run from the right working dir, will make another pr for future changes

@tomusdrw tomusdrw deleted the autogen-config-docs branch December 28, 2018 12:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants