actiondoc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +12 -0
- data/.github/workflows/README.md.no-template +13 -0
- data/.github/workflows/README.md.with-template +48 -0
- data/.github/workflows/action-tests.yml +42 -0
- data/.github/workflows/docker-build.yml +46 -0
- data/.github/workflows/generate-readme.yml +27 -0
- data/.github/workflows/tests.yml +49 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/actiondoc.gemspec +48 -0
- data/exe/actiondoc +6 -0
- data/lib/action.rb +12 -0
- data/lib/actiondoc/generator.rb +83 -0
- data/lib/actiondoc/templates/default.erb +5 -0
- data/lib/actiondoc/version.rb +5 -0
- data/lib/actiondoc.rb +61 -0
- data/lib/table_layouts.rb +42 -0
- data/templates/README.md.erb +40 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 93d5b5065266ea804bd9ec0900e26f7d5adcff589e2ed8420a8a82db27c73645
|
4
|
+
data.tar.gz: 4d7b319c346f3cf5dc5249403075561428a164e17af2351a392310c9b45bbd0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87e10ec6a11240a4a1bfd0794b972f8c3a0e0a0366f948a7670b18b0c675672ac7541b3d4446912278d0be15884a3fec5c62e736d0ec9c6abf0aadcb71eb9cab
|
7
|
+
data.tar.gz: fa61a6c0cb713c0b98c7e53177cac5f4c2997c5299ffc97a647b0534f9177da52e707425353d223a02ba9b847cf6d550be9a1266a5ef84163a24440214399a7b
|
data/.dockerignore
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
actiondoc
|
2
|
+
====
|
3
|
+
|
4
|
+
Generates documentation from your GitHub Action's `action.yml`
|
5
|
+
|
6
|
+
## Inputs
|
7
|
+
|
8
|
+
| Name | Description | Required | Default |
|
9
|
+
|--------------------|-----------------------------------------------------------------------------------------|----------|---------|
|
10
|
+
| template-filename | The path to the ERB template to use to generate the documentation. | No | |
|
11
|
+
| output-filename | The filename to save the output to. If not specified, simply prints to standard output. | No | |
|
12
|
+
| path-to-action-yml | The path to the `action.yml` file to generate documentation for. | No | |
|
13
|
+
| working-directory | The directory to perform the action in, if not $GITHUB_WORKSPACE | No | |
|
@@ -0,0 +1,48 @@
|
|
1
|
+
actiondoc
|
2
|
+
====
|
3
|
+
|
4
|
+
[](https://github.com/aisrael/actiondoc/actions/workflows/tests.yml)
|
5
|
+
|
6
|
+
Generates documentation from your GitHub Action's `action.yml`
|
7
|
+
|
8
|
+
## Inputs
|
9
|
+
|
10
|
+
| Name | Description | Required | Default |
|
11
|
+
|--------------------|-----------------------------------------------------------------------------------------|----------|---------|
|
12
|
+
| template-filename | The path to the ERB template to use to generate the documentation. | No | |
|
13
|
+
| output-filename | The filename to save the output to. If not specified, simply prints to standard output. | No | |
|
14
|
+
| path-to-action-yml | The path to the `action.yml` file to generate documentation for. | No | |
|
15
|
+
| working-directory | The directory to perform the action in, if not $GITHUB_WORKSPACE | No | |
|
16
|
+
|
17
|
+
See [Basic Usage](features/basic_usage.feature) for some basic usage.
|
18
|
+
|
19
|
+
### Example
|
20
|
+
|
21
|
+
Given an `action.yml` that contains:
|
22
|
+
|
23
|
+
```yaml
|
24
|
+
name: actiondoc
|
25
|
+
description: >-
|
26
|
+
Generates documentation from your GitHub Action's `action.yml`
|
27
|
+
|
28
|
+
inputs:
|
29
|
+
path-to-action-yml:
|
30
|
+
description: >-
|
31
|
+
The path to the `action.yml` file to generate documentation for.
|
32
|
+
required: false
|
33
|
+
```
|
34
|
+
|
35
|
+
Then when running `actiondoc` it should output
|
36
|
+
|
37
|
+
```markdown
|
38
|
+
actiondoc
|
39
|
+
====
|
40
|
+
|
41
|
+
Generates documentation from your GitHub Action's `action.yml`
|
42
|
+
|
43
|
+
## Inputs
|
44
|
+
|
45
|
+
| Name | Description | Required | Default |
|
46
|
+
|--------------------|------------------------------------------------------------------|----------|---------|
|
47
|
+
| path-to-action-yml | The path to the `action.yml` file to generate documentation for. | No | |
|
48
|
+
```
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Action Tests
|
2
|
+
on: push
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
test-with-defaults:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v3
|
9
|
+
- run: |
|
10
|
+
ls -l .
|
11
|
+
- name: Given
|
12
|
+
run: if [ -f README.md ]; then rm README.md; fi
|
13
|
+
- name: Test with defaults
|
14
|
+
uses: ./.
|
15
|
+
with:
|
16
|
+
output-filename: README.md
|
17
|
+
- run: |
|
18
|
+
ls -l .
|
19
|
+
- name: Assertions
|
20
|
+
run: |
|
21
|
+
cat README.md
|
22
|
+
[ -f README.md ] && diff README.md .github/workflows/README.md.no-template
|
23
|
+
|
24
|
+
test-with-template:
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@v3
|
28
|
+
- run: |
|
29
|
+
ls -l .
|
30
|
+
- name: Given
|
31
|
+
run: if [ -f README.md ]; then rm README.md; fi
|
32
|
+
- name: Test with defaults
|
33
|
+
uses: ./.
|
34
|
+
with:
|
35
|
+
template-filename: templates/README.md.erb
|
36
|
+
output-filename: README.md
|
37
|
+
- run: |
|
38
|
+
ls -l .
|
39
|
+
- name: Assertions
|
40
|
+
run: |
|
41
|
+
cat README.md
|
42
|
+
[ -f README.md ] && diff README.md .github/workflows/README.md.with-template
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Build Docker Image
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
6
|
+
paths:
|
7
|
+
- "!.github/workflows/**"
|
8
|
+
- .github/workflows/docker-build.yml
|
9
|
+
- "lib/**"
|
10
|
+
- "exe/**"
|
11
|
+
- actiondoc.gemspec
|
12
|
+
- Dockerfile
|
13
|
+
- Gemfile
|
14
|
+
- Rakefile
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
docker-build:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v3
|
21
|
+
- name: Set up Docker Buildx
|
22
|
+
uses: docker/setup-buildx-action@v2
|
23
|
+
# So now you can use Actions' own caching!
|
24
|
+
- name: Cache Docker layers
|
25
|
+
uses: actions/cache@v3
|
26
|
+
with:
|
27
|
+
path: /tmp/.buildx-cache
|
28
|
+
key: ${{ runner.os }}-buildx-${{ inputs.git-hash || github.sha }}
|
29
|
+
restore-keys: |
|
30
|
+
${{ runner.os }}-buildx-
|
31
|
+
- name: Login to GitHub Container Registry
|
32
|
+
uses: docker/login-action@v2
|
33
|
+
with:
|
34
|
+
registry: ghcr.io
|
35
|
+
username: ${{ github.repository_owner }}
|
36
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
37
|
+
- run: |
|
38
|
+
rake build
|
39
|
+
- name: Build and push
|
40
|
+
uses: docker/build-push-action@v3
|
41
|
+
with:
|
42
|
+
context: .
|
43
|
+
push: true
|
44
|
+
tags: |
|
45
|
+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
46
|
+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:0.1.0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Generate README
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
paths:
|
5
|
+
- action.yml
|
6
|
+
- templates/**
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
generate-readme:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
- run: if [ -f README.md ]; then rm README.md; fi
|
14
|
+
- name: Test with defaults
|
15
|
+
uses: ./.
|
16
|
+
with:
|
17
|
+
template-filename: templates/README.md.erb
|
18
|
+
output-filename: README.md
|
19
|
+
- run: |
|
20
|
+
cat README.md
|
21
|
+
- name: Create Pull Request
|
22
|
+
uses: peter-evans/create-pull-request@v4
|
23
|
+
with:
|
24
|
+
add-paths: README.md
|
25
|
+
branch: update-readme
|
26
|
+
delete-branch: true
|
27
|
+
title: Update README.md
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: Rubocop and Tests
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
paths-ignore:
|
5
|
+
- README.md
|
6
|
+
pull_request:
|
7
|
+
branches:
|
8
|
+
- main
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
rubocop:
|
12
|
+
name: Rubocop
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- name: Checkout Code
|
16
|
+
uses: actions/checkout@v3
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
# runs 'bundle install' and caches installed gems automatically
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Run RuboCop
|
23
|
+
run: bundle exec rubocop --parallel
|
24
|
+
|
25
|
+
unit-tests:
|
26
|
+
name: Unit tests
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
steps:
|
29
|
+
- name: Checkout Code
|
30
|
+
uses: actions/checkout@v3
|
31
|
+
- name: Set up Ruby
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
bundler-cache: true
|
35
|
+
- name: Run the tests
|
36
|
+
run: bundle exec rake test
|
37
|
+
|
38
|
+
cucumber-tests:
|
39
|
+
name: Cucumber tests
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
steps:
|
42
|
+
- name: Checkout Code
|
43
|
+
uses: actions/checkout@v3
|
44
|
+
- name: Set up Ruby
|
45
|
+
uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
bundler-cache: true
|
48
|
+
- name: Run the tests
|
49
|
+
run: bundle exec cucumber
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Alistair Israel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/actiondoc.gemspec
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/actiondoc/version'
|
4
|
+
|
5
|
+
DOCKERIGNORE_GLOBS = File.readlines('.dockerignore').map(&:chomp)
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'actiondoc'
|
9
|
+
spec.version = ActionDoc::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.authors = ['Alistair Israel']
|
12
|
+
spec.email = ['aisrael@gmail.com']
|
13
|
+
|
14
|
+
spec.summary = 'Generate documentation for GitHub Actions'
|
15
|
+
spec.description = 'Ruby Gem to generate documentation for GitHub Actions'
|
16
|
+
spec.homepage = 'https://github.com/aisrael/actiondoc'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.7.1')
|
19
|
+
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
|
22
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
23
|
+
spec.metadata['source_code_uri'] = 'https://github.com/aisrael/actiondoc'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/aisrael/actiondoc/blob/main/CHANGELOG.md'
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
f.match(%r{^(test|spec|features)/}) || DOCKERIGNORE_GLOBS.any? do |glob|
|
31
|
+
File.fnmatch(glob, f) || (glob.end_with?('/') && f.start_with?(glob))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
spec.bindir = 'exe'
|
36
|
+
spec.executables = ['actiondoc']
|
37
|
+
spec.require_paths = ['lib']
|
38
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
39
|
+
|
40
|
+
spec.add_development_dependency 'aruba', '~> 2.1.0'
|
41
|
+
spec.add_development_dependency 'contracts', '0.16.1'
|
42
|
+
spec.add_development_dependency 'cucumber', '~> 8.0.0'
|
43
|
+
spec.add_development_dependency 'minitest', '~> 5.16.3'
|
44
|
+
spec.add_development_dependency 'rake', '~> 13.0.6'
|
45
|
+
spec.add_development_dependency 'rubocop', '~> 1.39.0'
|
46
|
+
spec.add_development_dependency 'rubocop-minitest', '~> 0.23.2'
|
47
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
48
|
+
end
|
data/exe/actiondoc
ADDED
data/lib/action.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Action = Struct.new(:name, :description, :inputs)
|
4
|
+
|
5
|
+
Input = Struct.new(:name, :description, :required, :default) do
|
6
|
+
class << self
|
7
|
+
def members_as_headers
|
8
|
+
members.map(&:to_s).map(&:capitalize)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
INPUTS_HEADERS = Input.members.map { |s| s.to_s.capitalize }.freeze
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'action'
|
4
|
+
require 'erb'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'table_layouts'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
TEMPLATES_DIR = File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
module ActionDoc
|
12
|
+
# The documentation generator class
|
13
|
+
class Generator
|
14
|
+
attr_reader :args, :options, :padding
|
15
|
+
|
16
|
+
# Initialize an instance of this `Generator` class
|
17
|
+
def initialize(args, options)
|
18
|
+
@args = args
|
19
|
+
@options = options
|
20
|
+
@padding = options.fetch(:padding, :nice)
|
21
|
+
end
|
22
|
+
|
23
|
+
def run
|
24
|
+
action = read_action_yml
|
25
|
+
template_filename = options[:template] || File.join(TEMPLATES_DIR, 'default.erb')
|
26
|
+
render_template(template_filename, action)
|
27
|
+
end
|
28
|
+
|
29
|
+
def read_action_yml
|
30
|
+
yaml = YAML.safe_load(File.read('action.yml')).deep_symbolize_keys
|
31
|
+
inputs = yaml.fetch(:inputs, {}).map do |k, v|
|
32
|
+
Input.new(k, v[:description], v[:required] ? 'Required' : 'No', v[:default])
|
33
|
+
end
|
34
|
+
Action.new(*(yaml.values_at(:name, :description) + [inputs]))
|
35
|
+
end
|
36
|
+
|
37
|
+
def render_template(template_filename, action)
|
38
|
+
inputs_table = construct_inputs_table(action)
|
39
|
+
template = ERB.new(File.read(template_filename), trim_mode: '-')
|
40
|
+
model = TemplateModel.new(action, inputs_table)
|
41
|
+
puts template.result(model.instance_eval { binding })
|
42
|
+
end
|
43
|
+
|
44
|
+
def construct_inputs_table(action)
|
45
|
+
TableLayouts::Nice.new(Input.members_as_headers, action.inputs).layout
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
INPUTS_SECTION_ERB = <<~ERB
|
50
|
+
|
51
|
+
## Inputs
|
52
|
+
|
53
|
+
<% inputs_table.each do |row| -%>
|
54
|
+
<%= "|" + row.join("|") + "|" %>
|
55
|
+
<% end -%>
|
56
|
+
ERB
|
57
|
+
|
58
|
+
# For ERB binding
|
59
|
+
TemplateModel = Struct.new(:action, :inputs_table) do
|
60
|
+
def inputs_section
|
61
|
+
return if inputs_table.nil? || inputs_table.empty?
|
62
|
+
|
63
|
+
ERB.new(INPUTS_SECTION_ERB, trim_mode: '-').result(binding)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Monkey patch Hash
|
69
|
+
module HashExt
|
70
|
+
def deep_symbolize_keys
|
71
|
+
transform_keys(&:to_sym).transform_values do |v|
|
72
|
+
case v
|
73
|
+
when Hash
|
74
|
+
v.deep_symbolize_keys
|
75
|
+
when Array
|
76
|
+
v.map { |e| e.is_a?(Hash) ? e.deep_symbolize_keys : e }
|
77
|
+
else
|
78
|
+
v
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
Hash.include HashExt
|
data/lib/actiondoc.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'actiondoc/generator'
|
4
|
+
require 'actiondoc/version'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
# The ActionDoc CLI
|
8
|
+
module ActionDoc
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# The main CLI entrypoint
|
13
|
+
def run
|
14
|
+
options = parse_options
|
15
|
+
|
16
|
+
if options[:version]
|
17
|
+
display_version
|
18
|
+
else
|
19
|
+
ActionDoc::Generator.new(ARGV, options).run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Builds the OptionParser and parses the options
|
24
|
+
def parse_options
|
25
|
+
options = {}
|
26
|
+
|
27
|
+
optparser = build_optparser(options)
|
28
|
+
begin
|
29
|
+
optparser.parse!
|
30
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
31
|
+
puts $ERROR_INFO.to_s
|
32
|
+
puts optparser
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
options
|
37
|
+
end
|
38
|
+
|
39
|
+
# Builds and returns the OptionParser
|
40
|
+
def build_optparser(options)
|
41
|
+
OptionParser.new do |opts|
|
42
|
+
opts.banner = 'Usage: actiondoc [options]'
|
43
|
+
|
44
|
+
opts.on('--template=TEMPLATE_FILENAME', '-t=TEMPLATE_FILENAME', 'The template to use') do |template_filename|
|
45
|
+
options[:template] = template_filename
|
46
|
+
end
|
47
|
+
opts.on('--version', 'Show the version') do
|
48
|
+
options[:version] = true
|
49
|
+
end
|
50
|
+
opts.on('--help', 'Display this help text') do
|
51
|
+
puts opts
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Print out the version (in the VERSION file)
|
57
|
+
def display_version
|
58
|
+
puts "actiondoc v#{ActionDoc::VERSION}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Table layouts
|
4
|
+
module TableLayouts
|
5
|
+
# Nice layout
|
6
|
+
class Nice
|
7
|
+
def initialize(headers, data)
|
8
|
+
@headers = headers
|
9
|
+
@data = data
|
10
|
+
end
|
11
|
+
|
12
|
+
def find_max_column_widths
|
13
|
+
all = [@headers] + @data
|
14
|
+
longest_row = all.inject(0) { |max, row| [row.length, max].max }
|
15
|
+
init = Array.new(longest_row, 0)
|
16
|
+
all.inject(init) do |memo, row|
|
17
|
+
memo.zip(row.map(&:to_s).map(&:length)).map { |pair| pair.compact.max }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def layout
|
22
|
+
max_column_widths = find_max_column_widths
|
23
|
+
padded_column_widths = max_column_widths.map { |w| w + 2 }
|
24
|
+
padded_headers = pad_row(padded_column_widths, @headers)
|
25
|
+
separators = generate_separators(padded_column_widths)
|
26
|
+
padded_data = @data.map do |row|
|
27
|
+
pad_row(padded_column_widths, row)
|
28
|
+
end
|
29
|
+
[padded_headers, separators] + padded_data
|
30
|
+
end
|
31
|
+
|
32
|
+
def pad_row(padded_column_widths, row)
|
33
|
+
padded_column_widths.zip(row).map do |width, col|
|
34
|
+
" #{col}".ljust(width)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_separators(widths)
|
39
|
+
widths.map { |width| '-' * width }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<%= action.name %>
|
2
|
+
====
|
3
|
+
|
4
|
+
[](https://github.com/aisrael/actiondoc/actions/workflows/tests.yml)
|
5
|
+
|
6
|
+
<%= action.description %>
|
7
|
+
<%= inputs_section -%>
|
8
|
+
|
9
|
+
See [Basic Usage](features/basic_usage.feature) for some basic usage.
|
10
|
+
|
11
|
+
### Example
|
12
|
+
|
13
|
+
Given an `action.yml` that contains:
|
14
|
+
|
15
|
+
```yaml
|
16
|
+
name: actiondoc
|
17
|
+
description: >-
|
18
|
+
Generates documentation from your GitHub Action's `action.yml`
|
19
|
+
|
20
|
+
inputs:
|
21
|
+
path-to-action-yml:
|
22
|
+
description: >-
|
23
|
+
The path to the `action.yml` file to generate documentation for.
|
24
|
+
required: false
|
25
|
+
```
|
26
|
+
|
27
|
+
Then when running `actiondoc` it should output
|
28
|
+
|
29
|
+
```markdown
|
30
|
+
actiondoc
|
31
|
+
====
|
32
|
+
|
33
|
+
Generates documentation from your GitHub Action's `action.yml`
|
34
|
+
|
35
|
+
## Inputs
|
36
|
+
|
37
|
+
| Name | Description | Required | Default |
|
38
|
+
|--------------------|------------------------------------------------------------------|----------|---------|
|
39
|
+
| path-to-action-yml | The path to the `action.yml` file to generate documentation for. | No | |
|
40
|
+
```
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actiondoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alistair Israel
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aruba
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: contracts
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.16.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.16.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cucumber
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 8.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 8.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 5.16.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 5.16.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 13.0.6
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 13.0.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.39.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.39.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.23.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.23.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.6.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.6.0
|
125
|
+
description: Ruby Gem to generate documentation for GitHub Actions
|
126
|
+
email:
|
127
|
+
- aisrael@gmail.com
|
128
|
+
executables:
|
129
|
+
- actiondoc
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".dockerignore"
|
134
|
+
- ".github/workflows/README.md.no-template"
|
135
|
+
- ".github/workflows/README.md.with-template"
|
136
|
+
- ".github/workflows/action-tests.yml"
|
137
|
+
- ".github/workflows/docker-build.yml"
|
138
|
+
- ".github/workflows/generate-readme.yml"
|
139
|
+
- ".github/workflows/tests.yml"
|
140
|
+
- Gemfile
|
141
|
+
- LICENSE
|
142
|
+
- actiondoc.gemspec
|
143
|
+
- exe/actiondoc
|
144
|
+
- lib/action.rb
|
145
|
+
- lib/actiondoc.rb
|
146
|
+
- lib/actiondoc/generator.rb
|
147
|
+
- lib/actiondoc/templates/default.erb
|
148
|
+
- lib/actiondoc/version.rb
|
149
|
+
- lib/table_layouts.rb
|
150
|
+
- templates/README.md.erb
|
151
|
+
homepage: https://github.com/aisrael/actiondoc
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata:
|
155
|
+
homepage_uri: https://github.com/aisrael/actiondoc
|
156
|
+
source_code_uri: https://github.com/aisrael/actiondoc
|
157
|
+
changelog_uri: https://github.com/aisrael/actiondoc/blob/main/CHANGELOG.md
|
158
|
+
rubygems_mfa_required: 'true'
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 2.7.1
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubygems_version: 3.1.2
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Generate documentation for GitHub Actions
|
178
|
+
test_files: []
|