Skip to content

Commit

Permalink
Merge pull request #170 from JohnLyman/markdown-compatibility
Browse files Browse the repository at this point in the history
(PDOC-233) markdown whitespace fixes
  • Loading branch information
eputnam authored Apr 3, 2018
2 parents 6eec154 + 6ba0350 commit a4e9150
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 31 deletions.
13 changes: 8 additions & 5 deletions lib/puppet-strings/markdown/templates/classes_and_defines.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,41 @@

<% if text -%>
<%= text %>

<% elsif summary -%>
<%= summary %>

<% else -%>
<%= "The #{name} class." %>

<% end -%>

<% if since -%>
* **Since** <%= since %>

<% end -%>
<% if see -%>
* **See also**
<% see.each do |sa| -%>
<% if sa[:name] -%>
<%= sa[:name] %>
<% end -%>
<% if sa[:text] -%>
<%= sa[:text] %>
<% end -%>
<% end -%>

<% end -%>
<% if examples -%>
#### Examples

<% examples.each do |eg| -%>
##### <%= eg[:name] %>

```puppet
<%= eg[:text] %>
```

<% end -%>
<% end -%>
<% if params %>
<% if params -%>
#### Parameters

The following parameters are available in the `<%= name %>` <%= @type %>.
Expand Down Expand Up @@ -60,4 +64,3 @@ Default value: <%= value_string(defaults[param[:name]]) %>
<% end -%>
<% end -%>
<% end -%>

5 changes: 2 additions & 3 deletions lib/puppet-strings/markdown/templates/function.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
### <%= name %>

Type: <%= type %>

<% if text -%>
<%= text %>

<% elsif summary -%>
<%= summary %>

<% else -%>
<%= "The #{name} class." %>

<% end -%>

<% signatures.each do |sig| -%>
#### `<%= sig.signature %>`

Expand Down
14 changes: 9 additions & 5 deletions lib/puppet-strings/markdown/templates/resource_type.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,41 @@

<% if text -%>
<%= text %>

<% elsif summary -%>
<%= summary %>

<% else -%>
<%= "The #{name} type." %>

<% end -%>

<% if since -%>
* **Since** <%= since %>

<% end -%>
<% if see -%>
* **See also**
<% see.each do |sa| -%>
<% if sa[:name] -%>
<%= sa[:name] %>
<% end -%>
<% if sa[:text] -%>
<%= sa[:text] %>
<% end -%>
<% end -%>

<% end -%>
<% if examples -%>
#### Examples

<% examples.each do |eg| -%>
##### <%= eg[:name] %>

```puppet
<%= eg[:text] %>
```

<% end -%>
<% end -%>
<% if properties %>
<% if properties -%>
#### Properties

The following properties are available in the `<%= name %>` <%= @type %>.
Expand Down Expand Up @@ -111,4 +116,3 @@ Default value: <%= value_string(param[:default]) %>
<% end -%>
<% end -%>
<% end -%>

5 changes: 5 additions & 0 deletions lib/puppet-strings/markdown/templates/table_of_contents.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<% if group.length > 0 -%>
## <%= group_name %>

<% if priv -%>
### Public <%= group_name %>

<% group.each do |item| -%>
<% unless item[:private] -%>
* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %>
<% end -%>
<% end -%>

### Private <%= group_name %>

<% group.each do |item| -%>
<% if item[:private] -%>
* `<%= item[:name] %>`: <%= item[:desc] %>
Expand All @@ -18,4 +22,5 @@
* [`<%= item[:name] %>`](#<%= item[:link] %>): <%= item[:desc] %>
<% end -%>
<% end -%>

<% end -%>
34 changes: 26 additions & 8 deletions spec/fixtures/unit/markdown/output.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
# Reference

## Classes

### Public Classes

* [`klass`](#klass): A simple class.

### Private Classes

* `noparams`: Overview for class noparams

## Defined types

* [`klass::dt`](#klassdt): A simple defined type.

## Resource types

* [`apt_key`](#apt_key): Example resource type using the new API.
* [`database`](#database): An example database server type.

## Functions

* [`func`](#func): A simple Puppet function.
* [`func3x`](#func3x): Documentation for an example 3.x function.
* [`func4x`](#func4x): An example 4.x function.
* [`func4x_1`](#func4x_1): An example 4.x function with only one signature.

## Tasks

* [`(stdin)`](#(stdin)): Allows you to backup your database to local file.

## Classes

### klass
Expand All @@ -28,9 +41,10 @@ An overview for a simple class.
* **See also**
www.puppet.com


#### Examples

##### This is an example

```puppet
class { 'klass':
param1 => 1,
Expand All @@ -39,14 +53,14 @@ class { 'klass':
```

##### This is another example

```puppet
class { 'klass':
param1 => 1,
param3 => 'foo',
}
```


#### Parameters

The following parameters are available in the `klass` class.
Expand Down Expand Up @@ -80,7 +94,6 @@ Third param.

Default value: 'hi'


## Defined types

### klass::dt
Expand All @@ -92,17 +105,17 @@ An overview for a simple defined type.
* **See also**
www.puppet.com


#### Examples

##### Here's an example of this type:

```puppet
klass::dt { 'foo':
param1 => 33,
param4 => false,
}
```


#### Parameters

The following parameters are available in the `klass::dt` defined type.
Expand Down Expand Up @@ -142,7 +155,6 @@ Fourth param.

Default value: `true`


## Resource types

### apt_key
Expand All @@ -155,7 +167,9 @@ If Puppet is given the location of a key file which looks like an absolute
path this type will autorequire that file.

#### Examples

##### here's an example

```puppet
apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
source => 'http://apt.puppetlabs.com/pubkey.gpg'
Expand Down Expand Up @@ -191,13 +205,14 @@ _*this data type contains a regex that may not be accurately reflected in genera

The ID of the key you want to manage.


### database

An example database server type.

#### Examples

##### here's an example

```puppet
database { 'foo':
address => 'qux.baz.bar',
Expand Down Expand Up @@ -252,10 +267,10 @@ Whether or not to encrypt the database.

Default value: `false`


## Functions

### func

Type: Puppet Language

A simple Puppet function.
Expand Down Expand Up @@ -292,6 +307,7 @@ Options:
* **:param3opt** `Array`: Something about this option

### func3x

Type: Ruby 3.x API

Documentation for an example 3.x function.
Expand All @@ -315,6 +331,7 @@ Data type: `Integer`
The second parameter.

### func4x

Type: Ruby 4.x API

An example 4.x function.
Expand Down Expand Up @@ -367,6 +384,7 @@ Data type: `Callable`
The block parameter.

### func4x_1

Type: Ruby 4.x API

An example 4.x function with only one signature.
Expand Down
Loading

0 comments on commit a4e9150

Please sign in to comment.