Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate clap-markdown in ghciwatch #248

Merged
merged 1 commit into from
May 20, 2024

Conversation

9999years
Copy link
Member

@9999years 9999years commented May 20, 2024

Blocked on #247

Cleans up ghciwatch --help and makes the docstrings render nicely as Markdown in an mdBook.

Copy link

linear bot commented May 20, 2024

@github-actions github-actions bot added the patch Bug fixes or non-functional changes label May 20, 2024
This was referenced May 20, 2024
- Add a hidden `--generate-markdown-help` option to generate Markdown
  docs for the CLI options
- Cleaned up the CLI help to include examples and make things render
  nicer
- Added more detail for some options
@9999years 9999years force-pushed the rebeccat/dux-2313-integrate-cli-documentation branch from c4ea57d to 5fde9a0 Compare May 20, 2024 19:36
@@ -51,7 +52,7 @@ indoc = "1.0.6"
itertools = "0.11.0"
line-span = "0.1.5"
miette = { version = "5.9.0", features = ["fancy"] }
nix = { version = "0.26.2", default_features = false, features = ["process", "signal"] }
nix = { version = "0.26.2", default-features = false, features = ["process", "signal"] }
Copy link
Member Author

Choose a reason for hiding this comment

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

Got a warning about this, maybe a toolchain update caught it? IDK.

/// Ghciwatch loads a GHCi session for a Haskell project and reloads it
/// when source files change.
///
/// ## Examples
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding some examples. This is a sort of weird compromise; these look decent in --help output unprocessed and also render as Markdown.

clap doesn't have any hooks to customize how the docstrings are preprocessed, so we have to turn off preprocessing (or it'll line-wrap the examples). Unfortunately, that loses us all formatting for this text...

/// Don't reload for `README.md` files:
///
/// ghciwatch --reload-glob '!src/**/README.md'
#[allow(rustdoc::invalid_rust_codeblocks)]
Copy link
Member Author

Choose a reason for hiding this comment

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

And rustdoc doesn't like that the indented shell examples aren't valid Rust code. (You're supposed to use triple backticks annotated as plain or something for that, but of course we don't want it to show up in the output.)

author,
verbatim_doc_comment,
max_term_width = 100,
override_usage = "ghciwatch [--command SHELL_COMMAND] [--watch PATH] [OPTIONS ...]"
Copy link
Member Author

Choose a reason for hiding this comment

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

--command and --watch are the really important options so I pulled them out; the default usage string was ghciwatch [OPTIONS] which isn't very useful.

///
/// By default, only changes to `.cabal` or `.ghci` files or Haskell source files being
/// moved/removed will trigger restarts.
///
/// Due to a `ghci` bug, the `ghci` session must be restarted when Haskell modules are removed
/// or renamed: https://gitlab.haskell.org/ghc/ghc/-/issues/11596
/// Due to [a `ghci` bug][1], the `ghci` session must be restarted when Haskell modules are removed
Copy link
Member Author

Choose a reason for hiding this comment

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

Kinda clumsy to have markdown link syntax in the --help output like this but it looks OK enough and it renders correctly as Markdown.

It'd be nice to have a system that let us do some more advanced templating to add more detail in the manual...

@9999years 9999years marked this pull request as ready for review May 20, 2024 19:40
@9999years 9999years merged commit bec0e44 into main May 20, 2024
28 checks passed
@9999years 9999years deleted the rebeccat/dux-2313-integrate-cli-documentation branch May 20, 2024 19:58
Copy link
Contributor

9999years added a commit that referenced this pull request May 20, 2024
~~Blocked on #248~~

Adds the actual user manual mdBook, but doesn't build or publish it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Bug fixes or non-functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants