webgme / webgme-engine

WebGME server and Client API without a GUI
MIT License
11 stars 7 forks source link

Simplify management of documentation of default configuration #307

Open pmeijer opened 1 year ago

pmeijer commented 1 year ago

The ./config/config.default.js should contain the documentation as well as the default values.

Suggestion is to augment the json structure with metadata such as doc, type, category, value etc. When requiring the file as a config - the structure should be transformed back into the regular config format.

Depending on the category the config variables would be listed from "default", "advanced", "cli".

Example of how the format could look like:

    config = {
        addOn: {
            doc: "AddOn are stateful server workers listening in on changes made to a branch",
            type: "container",
            category: "default",
            enable: {
                doc: "If true enables add-ons",
                value: false
            },
            monitorTimeout: {
                category: "advanced",
                doc: "In milliseconds, the waiting time before add-ons are stopped after no activity (new clients joined or hash updates) in the branch.",
                displayValue: '2 * 60 * 1000',
                value: 2 * 60 * 1000,
            },
            workerUrl: {
                category: "advanced",
                doc: "If given the webgme server will not spawn a child process for running add-ons and instead post the related events to the url. Use addon_handler.js for a machine handling such requests.",
                value: null
            },
            basePaths: {
                category: "cli",
                doc: "Array of paths to custom add-ons. If you have an add-on at `C:/SomeAddOns/MyAddOn/MyAddOn.js` the path to append would be `C:/SomeAddOns` or a relative path (from the current working directory). N.B. this will also expose any other add-on in that directory, e.g. `C:/SomeAddOns/MyOtherAddOn/MyOtherAddOn.js`.",
                type: "array",
                displayValue: "[path.join(__dirname, '../src/addon/core')]",
                value: [path.join(__dirname, '../src/addon/core')]
            }
        },
...
brollb commented 1 year ago

Have we looked at other libraries that could help us here? I just want to make sure we aren't re-inventing the wheel :)

Also, are we planning on updating the generated documentation to include this?

pmeijer commented 1 year ago

No but that’s a good point. I’m just adding the requirements I had in mind here to open up a discussion about it. Yes it should generate the docs. Probably also add a test that checks that the docs are in sync with the latest config file. Any suggestions are welcomed.