Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
* Generate dokka
* Update mkdocs version
* Group adjacent code blocks into tabs
* Switch api docs to gfm format
  • Loading branch information
ajalt committed May 12, 2019
1 parent b820559 commit 87b8583
Show file tree
Hide file tree
Showing 805 changed files with 6,939 additions and 12,952 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
### Changed
- If multiple `--` tokens are present on the command line, all subsequent occurrences after the first are now parsed as positional arguments. Previously, subsequent `--` tokens were skipped.
- The `PlaintextHelpFormatter` has been replaced with `CliktHelpFormatter`, which is more customizable. See [the docs](https://ajalt.github.io/clikt/documenting/) for more info, or the [new sample](samples/ansicolors/README.md) for an example of customizing help output to use ANSI colors.
- Some of the properties and constructor parameters for [`OptionWithValues`](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.parameters.options/-option-with-values/index.html) and [`ProcessedArgument`](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.parameters.arguments/-processed-argument/index.html) have changed.
- Some of the properties and constructor parameters for [`OptionWithValues`](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.parameters.options/-option-with-values/) and [`ProcessedArgument`](https://ajalt.github.io/clikt/api/clikt/com.github.ajalt.clikt.parameters.arguments/-processed-argument/) have changed.
- The `OptionDelegate` interface has changed, and `GroupableOption` and `ParameterHolder` interfaces have been added to work with option groups.
- [Parameter validation](https://ajalt.github.io/clikt/parameters/#parameter-validation) now occurs after all parameter delegates have set their values, so the lambdas passed to `validate` may reference other parameters.

Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ buildscript {

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.18"
}
}

apply plugin: 'idea'
apply plugin: 'org.jetbrains.dokka'

repositories {
mavenCentral()
jcenter()
}

subprojects {
apply plugin: 'kotlin'

Expand Down
1 change: 1 addition & 0 deletions clikt/build.gradle
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ artifacts {

dokka {
outputDirectory = "$rootDir/docs/api"
outputFormat = 'gfm'
}

ext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.github.ajalt.clikt.parameters.arguments.Argument
import com.github.ajalt.clikt.parameters.arguments.convert
import com.github.ajalt.clikt.parameters.groups.ParameterGroup
import com.github.ajalt.clikt.parameters.options.Option
import kotlin.math.exp

/**
* An internal error that signals Clikt to abort.
Expand Down
24 changes: 11 additions & 13 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ like the way you can configure git to accept `git ci` as an alias for
`git commit`.

To implement command aliases, override
[`CliktCommand.aliases`](api/clikt/com.github.ajalt.clikt.core/-clikt-command/aliases.html) in your
[`CliktCommand.aliases`](/api/clikt/com.github.ajalt.clikt.core/-clikt-command/aliases/) in your
command. This function is called once at the start of parsing, and returns a map of aliases to the
tokens that they alias to.

To implement git-style aliases:

```kotlin
```kotlin tab="Example"
class Repo : NoRunCliktCommand() {
// You could load the aliases from a config file etc.
override fun aliases(): Map<String, List<String>> = mapOf(
Expand All @@ -37,14 +37,12 @@ class Commit: CliktCommand() {
fun main(args: Array<String>) = Repo().subcommands(Commit()).main(args)
```

And on the command line:

```
```text tab="Usage 1"
$ ./repo ci -m 'my message'
Committing with message: my message
```

```
```text tab="Usage 2"
$ ./repo cm 'my message'
Committing with message: my message
```
Expand Down Expand Up @@ -100,12 +98,12 @@ Running Bar

To prevent ambiguities in parsing, aliases are only supported for
command names. However, there's another way to modify user input that
works on more types of tokens. You can set a [`tokenTransformer`](api/clikt/com.github.ajalt.clikt.core/-context/token-transformer.html) on the
works on more types of tokens. You can set a [`tokenTransformer`](/api/clikt/com.github.ajalt.clikt.core/-context/token-transformer/) on the
[command's context](commands.md#customizing-contexts) that will be
called for each option and command name that is input. This can be used
to implement case-insensitive parsing, for example:

```kotlin
```kotlin tab="Example"
class Hello : CliktCommand() {
init {
context { tokenTransformer = { it.toLowerCase() } }
Expand All @@ -116,18 +114,18 @@ class Hello : CliktCommand() {
}
```

```
```text tab="Usage"
$ ./hello --NAME=Foo
Hello Foo!
```

## Replacing stdin and stdout

By default, functions like [`CliktCommand.main`](api/clikt/com.github.ajalt.clikt.core/-clikt-command/main.html)
and [`option().prompt()`](api/clikt/com.github.ajalt.clikt.parameters.options/prompt.html)
By default, functions like [`CliktCommand.main`](/api/clikt/com.github.ajalt.clikt.core/-clikt-command/main/)
and [`option().prompt()`](/api/clikt/com.github.ajalt.clikt.parameters.options/prompt/)
read from `System.in` and write to `System.out`. If you want to use
clikt in an environment where the standard streams aren't available, you
can set your own implementation of [`CliktConsole`](api/clikt/com.github.ajalt.clikt.output/-clikt-console/index.html)
can set your own implementation of [`CliktConsole`](/api/clikt/com.github.ajalt.clikt.output/-clikt-console/)
when [customizing the command context](commands.md#customizing-contexts).

```kotlin
Expand All @@ -153,7 +151,7 @@ class CustomCLI : CliktCommand() {
```

If you are using
[`TermUI`](api/clikt/com.github.ajalt.clikt.output/-term-ui/index.html)
[`TermUI`](/api/clikt/com.github.ajalt.clikt.output/-term-ui/)
directly, you can also pass your custom console as an argument.

## Command Line Argument Files
Expand Down
Loading

0 comments on commit 87b8583

Please sign in to comment.