Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Sep 15, 2024
1 parent 2549cf3 commit f498fb4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Added `associate{}`, `associateBy{}`, and `associateWith{}` transforms for options that allow you to convert the keys and values of the map. ([#529](https://github.com/ajalt/clikt/pull/529))
- Added support for aliasing options to other options. ([#535](https://github.com/ajalt/clikt/pull/535))
- Added `limit` and `ignoreCase` parameters to `option().split()`. ([#541](https://github.com/ajalt/clikt/pull/541))
- Support calling `--help` on subcommands when parents have required parameters.

### Changed
- In a subcommand with and an `argument()` with `multiple()` or `optional()`, the behavior is now the same regardless of the value of `allowMultipleSubcommands`: if a token matches a subcommand name, it's now treated as a subcommand rather than a positional argument.
Expand All @@ -39,8 +40,8 @@
- **Breaking Change:** `CliktCommand.main` and `CliktCommand.parse` are now extension functions rather than methods.
- **Breaking Change:** `Context.obj` and `Context.terminal`, and `OptionTransformContext.terminal` are now extension functions rather than properties.
- **Breaking Change:** The `RenderedSection` and `DefinitionRow` classes have moved to `AbstractHelpFormatter`.
- Markdown support in the help formatter is no longer included by default. To enable it, include the `:clikt-markdown` dependency and call `yourCommand.installMordantMarkdown()` before parsing.
- Updated Kotlin to 2.0.0
- Support calling `--help` on subcommands when parents have required parameters.

### Fixed
- Fixed excess arguments not being reported when `allowMultipleSubcommands=true` and a subcommand has excess arguments followed by another subcommand.
Expand Down
5 changes: 3 additions & 2 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ dependencies {
```

The [CliktCommand] class is only available in the full module, so you'll need to use
[CoreCliktCommand] instead. The `CoreCliktCommand` has the same API as `CliktCommand`, but it
[CoreCliktCommand] (or [CoreNoOpCliktCommand]) instead. The `CoreCliktCommand` has the same API as `CliktCommand`, but it
doesn't have any of these features built in:

- Text wrapping, formatting, markdown, or color support
Expand Down Expand Up @@ -640,7 +640,8 @@ These platforms are supported for the [core module](#core-module) only.

[BaseCliktCommand]: api/clikt/com.github.ajalt.clikt.core/-base-clikt-command/index.html
[CliktCommand]: api/clikt-mordant/com.github.ajalt.clikt.core/-clikt-command/index.html
[CliktCommand]: api/clikt/com.github.ajalt.clikt.core/-core-clikt-command/index.html
[CoreCliktCommand]: api/clikt/com.github.ajalt.clikt.core/-core-clikt-command/index.html
[CoreNoOpCliktCommand]: api/clikt/com.github.ajalt.clikt.core/-core-no-op-clikt-command/index.html
[CommandLineParser]: api/clikt/com.github.ajalt.clikt.parsers/-command-line-parser/index.html
[CommandLineParser.main]: api/clikt/com.github.ajalt.clikt.parsers/-command-line-parser/main.html
[CommandLineParser.parse]: api/clikt/com.github.ajalt.clikt.parsers/-command-line-parser/parse.html
Expand Down
23 changes: 21 additions & 2 deletions docs/documenting.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,31 @@ describe arguments in the command help.

## Markdown in help texts

All help texts use Mordant to render Markdown. You can use all the normal markdown features, such as
lists, tables, and even hyperlinks if your terminal supports them.
You can configure Clikt to use Mordant to render Markdown in help texts. You can use all the normal
markdown features, such as lists, tables, and even hyperlinks if your terminal supports them.

First, add the `:clitk-markdown` dependency to your project:

```kotlin
dependencies {
implementation("com.github.ajalt.clikt:clikt-markdown:$cliktVersion")
}
```

And install the markdown help formatter on your command:

```kotlin
val command = MyCommand().installMordantMarkdown()
```

Then you can use markdown in your help strings:

=== "Example"
```kotlin
class Tool : NoOpCliktCommand() {
init {
installMordantMarkdown()
}
val option by option().help {
"""
| This | is | a | table |
Expand Down

0 comments on commit f498fb4

Please sign in to comment.