Skip to content

Commit

Permalink
Further Maven plugin docs (#35, #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvesse committed Nov 1, 2018
1 parent 0eda2ae commit d90c2b2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public HtmlCommandUsageGenerator(boolean includeHidden) {
public HtmlCommandUsageGenerator(String... stylesheetUrls) {
this(UsageHelper.DEFAULT_OPTION_COMPARATOR, false, stylesheetUrls);
}

public HtmlCommandUsageGenerator(boolean includeHidden, String... stylesheetUrls) {
this(UsageHelper.DEFAULT_OPTION_COMPARATOR, includeHidden, stylesheetUrls);
}

public HtmlCommandUsageGenerator(String stylesheetUrl, boolean includeHidden) {
this(UsageHelper.DEFAULT_OPTION_COMPARATOR, includeHidden, stylesheetUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.github.rvesse.airline.maven.formats;

import java.io.File;
import org.apache.commons.lang3.StringUtils;

import com.github.rvesse.airline.help.CommandGroupUsageGenerator;
import com.github.rvesse.airline.help.CommandUsageGenerator;
Expand All @@ -24,6 +25,7 @@

/**
* Provides HTML help generators
*
* @author rvesse
*
*/
Expand All @@ -39,9 +41,20 @@ public String getExtension(FormatOptions options) {
return ".html";
}

private String[] getStylesheets(FormatOptions options) {
String sheets = options.getProperty("stylesheet");
if (StringUtils.isBlank(sheets)) {
return new String[] { HtmlCommandUsageGenerator.DEFAULT_STYLESHEET };
} else if (sheets.contains(",")) {
return StringUtils.split(sheets, ',');
} else {
return new String[] { sheets };
}
}

@Override
public CommandUsageGenerator getCommandGenerator(File outputDirectory, FormatOptions options) {
return new HtmlCommandUsageGenerator(options.includeHidden());
return new HtmlCommandUsageGenerator(options.includeHidden(), getStylesheets(options));
}

@Override
Expand Down
70 changes: 68 additions & 2 deletions docs/guide/practise/maven-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ These elements are all supplied as child elements to the relevant top level elem
*Applicable Goals:* `airline:generate`
*Child Element Of:* `<defaultOptions>` and `<options>`

Specifies the integer number of columns to use for column wrapped output formats e.g.
Specifies the integer number of columns to use for column wrapped output formats, defaults to **79** e.g.

```xml
<columns>70</columns>
Expand All @@ -258,14 +258,60 @@ Specifies the integer number of columns to use for column wrapped output formats

Specifies the name of an output format. By default Airline recognizes the names `BASH`, `CLI`, `HTML`, `MAN` and `MARKDOWN` as referring to built in help formats. However this mapping can be redefined by the `<formatMappings>` element as desired.

```xml
<format>MAN</format>
```

#### `<includeHidden>`

*Applicable Goals:* `airline:generate`
*Child Element Of:* `<formats>` and `<mapping>`

Specifies whether hidden groups, commands and options should be included in the output. Defaults to **false**

```xml
<includeHidden>true</includeHidden>
```

#### `<manSection>`

*Applicable Goals:* `airline:generate`
*Child Element Of:* `<formats>` and `<mapping>`

Specifies what man section should be used for the output for formats that respect man section. Defaults to **1** which is General Commands.

```xml
<manSection>8</manSection>
```

#### `<mapping>`

*Applicable Goals:* `airline:generate`
*Child Element Of:* `<formatMappings>`

Defines a relationship between a format name used in a `<format>` element to an underlying {% include javadoc-ref.md class="FormatProvider" package="maven.formats" module="airline-maven-plugin" %}. Can also optionally specify default options for the format which would override `<defaultOptions>` but can also later be overridden by `<source>` options.

```xml
<mapping>
<format>CUSTOM</format>
<provider>some.package.YourFormatProvider</provider>
<options>
<columns>100</columns>
</options>
</mapping>
```

#### `<multiFile>`

*Applicable Goals:* `airline:generate`
*Child Element Of:* `<formats>` and `<mapping>`

Specifies whether output should be generated to multiple files when the format supports it. So to take Man pages for example when set to **true** will generate an individual output file per CLI, group and command whereas when set to **false** generates a single output file. Defaults to **false**.

```xml
<multiFile>true</multiFile>
```

#### `<outputMode>`

*Child Element Of:* `<source>`
Expand All @@ -274,4 +320,24 @@ Specifies the name of an output format. By default Airline recognizes the names

#### `<properties>`

#### `<provider>`
*Applicable Goals:* `airline:generate`
*Child Element Of:* `<formats>` and `<mapping>`

Specifies additional custom properties that may be used by output formats to further customise their output. This allows for free-form key value pairs where interpretation is up to the format provider without needing to extend the plugin to introduce new configuration.

```xml
<properties>
<stylesheet>css/my-style.css</stylesheet>
</properties>
```

#### `<provider>`

*Applicable Goals:* `airline:generate`
*Child Element Of:* `<mapping>`

Specifies the provider for a format. This can either be a fully qualified class name or can be the special value `default`. In the case of `default` whatever the default provider for the name declared by the `<format>` element of the `<mapping>` is will be used. Default providers are discovered using the JDK `ServiceLoader` so provided your custom provider is present on the plugins classpath and has an appropriate `com.github.rvesse.airline.maven.formats.FormatProvider` file in its `META-INF/services` folder then using the `<provider>` element will be unecessary.

```xml
<provider>some.package.YourCustomProvider</provider>
```

0 comments on commit d90c2b2

Please sign in to comment.