Skip to content

go:generate runtime/help/options.md - #4152

Open
usfbih8u wants to merge 5 commits into
micro-editor:masterfrom
usfbih8u:build-go-generate-markdown-options
Open

go:generate runtime/help/options.md#4152
usfbih8u wants to merge 5 commits into
micro-editor:masterfrom
usfbih8u:build-go-generate-markdown-options

Conversation

@usfbih8u

Copy link
Copy Markdown
Contributor

No description provided.

usfbih8u added 3 commits July 26, 2026 19:30
`generate_settings.go` is expected to be called with go:generate as part of the
build steps.
…ttings.go`

Move the option's documentation from `runtime/help/options.md` as comments in
`internal/config/settings.go` so it can be parsed with a go program.

NOTE: Tabs vs spaces inside the comment matters.
@usfbih8u

Copy link
Copy Markdown
Contributor Author

NOTES:

  • I use a lot of panic()s because I want correctness and the program to scream at you if something goes wrong or changes. The last thing we want is to generate garbage or incorrect data that passes unnoticed.

  • I tried to maximize the use of raw strings in generateMarkdownFile() as much as possible to make it easy to edit.

  • Diff with previous markdown file:

    • Some uses of backticks have been replaced with single quotes to enable raw string literals and provide clearer code here.
    • Some indentation changes (now that it is automated, can be mass changed).
    • "default value" keeps the double quotes in strings (intentionally).
    • Missing options for built-in plugins in the markdown-generated JSON example with all options in the "Settings.json file" section.
    • I'm not certain about the option-scope differentiation, but I parse it.
  • I ensure all built-in plugins are documented here (grep "pluginsInfo").

  • I was about to add info for validators, but I think it's better to let the editor handle that.

  • Tabs vs. spaces inside the comment matter for indentation in generated text.

TODOs:

  • I would like to create a proper section for "Plugin Options" instead of using "---".

  • Add a comment like <!-- File generated by generate_settings.go --> on the first line?

  • Leave ast.Print() commented? Maybe it's a nice hint for others for debugging if they aren't familiar with the ast package.

  • I'm not sure what to do with the local vs. global vs. all scope concept and section in the markdown file. https://github.com/micro-editor/micro/blob/master/runtime/help/options.md#global-and-local-settings

    • I would change the values of scopeString in case it's used in the generated text.
  • defaultFileFormat() and defaultFakeCursor() are treated specially in the code, and the value is hardcoded (grep for the identifier in generate_settings.go).

    • defaultFileFormat() in data/micro.json had the default set to "unix"; in runtime/help/options.md it was set to "default value: unix on Unix systems, dos on Windows". Maybe I can use the entire string above as the default, since it's hardcoded? Currently I use "unix" as default.
    • defaultFakeCursor(): Does not appear in data/micro.json; in markdown it is set to false (as well as here).

@usfbih8u

Copy link
Copy Markdown
Contributor Author

Feedback on this PR (related to this message) is much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant