rggen-markdown 0.13.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/rggen/markdown.rb +3 -5
- data/lib/rggen/markdown/register/markdown.erb +7 -5
- data/lib/rggen/markdown/register/markdown.rb +12 -1
- data/lib/rggen/markdown/register_block/markdown.erb +3 -3
- data/lib/rggen/markdown/register_block/markdown.rb +17 -10
- data/lib/rggen/markdown/setup.rb +1 -1
- data/lib/rggen/markdown/utility.rb +6 -5
- data/lib/rggen/markdown/utility/table_formatter.rb +52 -0
- data/lib/rggen/markdown/version.rb +1 -1
- metadata +7 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 399827f511dd221bd6e8b647aa33ae36c4d22022a7948fb99a8242e647ae0bb9
|
4
|
+
data.tar.gz: cd31131a1a3299717474f16983683a2f9854d136fc22ac104acff2a16c3a9460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afddc0aa9cadcd6e6672eb859a659239f9828577357caf063922dc29019f7cca018babf3a9d4c33f9fd1152390f09f79e3706e3c2a5e6013f64818850a7d868
|
7
|
+
data.tar.gz: 120a0d0084997adb97975a62bc99d8e27bdfa9a6da598b6971627e9b880e6191d5edd6d485f203d23dd3968de2a541f449eec27b45ac045eb6e001d73015f5db
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/rggen-markdown.svg)](https://badge.fury.io/rb/rggen-markdown)
|
2
|
-
[![
|
2
|
+
[![CI](https://github.com/rggen/rggen-markdown/workflows/CI/badge.svg)](https://github.com/rggen/rggen-markdown/actions?query=workflow%3ACI)
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/5bbd7d84fefb30c5ee9a/maintainability)](https://codeclimate.com/github/rggen/rggen-markdown/maintainability)
|
4
4
|
[![codecov](https://codecov.io/gh/rggen/rggen-markdown/branch/master/graph/badge.svg)](https://codecov.io/gh/rggen/rggen-markdown)
|
5
5
|
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rggen_rggen-markdown&metric=alert_status)](https://sonarcloud.io/dashboard?id=rggen_rggen-markdown)
|
@@ -34,7 +34,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
|
|
34
34
|
|
35
35
|
## Copyright & License
|
36
36
|
|
37
|
-
Copyright © 2019 Taichi Ishitani. RgGen::Markdown is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
|
37
|
+
Copyright © 2019-2020 Taichi Ishitani. RgGen::Markdown is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
|
38
38
|
|
39
39
|
## Code of Conduct
|
40
40
|
|
data/lib/rggen/markdown.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ruport'
|
4
|
-
require 'ruport/wiki_table_formatter'
|
5
|
-
|
6
3
|
require_relative 'markdown/version'
|
7
4
|
require_relative 'markdown/utility/source_file'
|
5
|
+
require_relative 'markdown/utility/table_formatter'
|
8
6
|
require_relative 'markdown/utility'
|
9
7
|
require_relative 'markdown/component'
|
10
8
|
require_relative 'markdown/feature'
|
@@ -20,10 +18,10 @@ module RgGen
|
|
20
18
|
def self.register_component(builder)
|
21
19
|
builder.output_component_registry(:markdown) do
|
22
20
|
register_component [
|
23
|
-
:
|
21
|
+
:root, :register_block, :register_file, :register, :bit_field
|
24
22
|
] do |category|
|
25
23
|
component Component, ComponentFactory
|
26
|
-
feature Feature, FeatureFactory if category != :
|
24
|
+
feature Feature, FeatureFactory if category != :root
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
|
2
|
-
### <%= anchor(anchor_id) %><%=
|
2
|
+
### <%= anchor(anchor_id) %><%= title %>
|
3
3
|
|
4
|
-
<%
|
4
|
+
<% register_printables.each do |name, value_or_values| %>
|
5
5
|
* <%= name %>
|
6
|
-
|
6
|
+
<% Array(value_or_values).each do |value| %>
|
7
|
+
* <%= trim_space(value) %>
|
8
|
+
<% end %>
|
7
9
|
<% end %>
|
8
|
-
<%
|
10
|
+
<% unless register.bit_fields.empty? %>
|
9
11
|
|
10
12
|
<%= bit_field_table %>
|
11
|
-
<% end%>
|
13
|
+
<% end %>
|
@@ -3,13 +3,24 @@
|
|
3
3
|
RgGen.define_simple_feature(:register, :markdown) do
|
4
4
|
markdown do
|
5
5
|
export def anchor_id
|
6
|
-
[register_block
|
6
|
+
[register_block, *register_files, register]
|
7
|
+
.map(&:name).join('-')
|
7
8
|
end
|
8
9
|
|
9
10
|
main_code :markdown, from_template: true
|
10
11
|
|
11
12
|
private
|
12
13
|
|
14
|
+
def title
|
15
|
+
register.printables[:layer_name]
|
16
|
+
end
|
17
|
+
|
18
|
+
def register_printables
|
19
|
+
register.printables
|
20
|
+
.reject { |key, _| [:name, :layer_name].include?(key) }
|
21
|
+
.compact
|
22
|
+
end
|
23
|
+
|
13
24
|
def bit_field_table
|
14
25
|
column_names = bit_field_printables.first.keys
|
15
26
|
rows =
|
@@ -1,8 +1,8 @@
|
|
1
|
-
## <%=
|
1
|
+
## <%= title %>
|
2
2
|
|
3
|
-
<%
|
3
|
+
<% register_block_printables.each do |name, printable| %>
|
4
4
|
* <%= name %>
|
5
|
-
* <%= printable
|
5
|
+
* <%= trim_space(printable) %>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<%= register_table %>
|
@@ -8,7 +8,7 @@ RgGen.define_simple_feature(:register_block, :markdown) do
|
|
8
8
|
|
9
9
|
write_file '<%= register_block.name %>.md' do |file|
|
10
10
|
file.body do |code|
|
11
|
-
register_block.generate_code(:markdown, :top_down
|
11
|
+
register_block.generate_code(code, :markdown, :top_down)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -16,21 +16,28 @@ RgGen.define_simple_feature(:register_block, :markdown) do
|
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
+
def title
|
20
|
+
register_block.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def register_block_printables
|
24
|
+
register_block.printables
|
25
|
+
.reject { |key, _| key == :name }
|
26
|
+
.compact
|
27
|
+
end
|
28
|
+
|
19
29
|
def register_table
|
20
|
-
table([:name
|
30
|
+
table([:name], table_rows)
|
21
31
|
end
|
22
32
|
|
23
33
|
def table_rows
|
24
|
-
register_block.registers
|
25
|
-
.zip(register_block.registers.map(&:printables))
|
26
|
-
.map { |register, printables| table_row(register, printables) }
|
34
|
+
register_block.registers.map(&method(:table_row))
|
27
35
|
end
|
28
36
|
|
29
|
-
def table_row(register
|
30
|
-
[
|
31
|
-
|
32
|
-
|
33
|
-
]
|
37
|
+
def table_row(register)
|
38
|
+
name = register.printables[:layer_name]
|
39
|
+
id = register.anchor_id
|
40
|
+
[anchor_link(name, id)]
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
data/lib/rggen/markdown/setup.rb
CHANGED
@@ -19,11 +19,12 @@ module RgGen
|
|
19
19
|
"[#{text}](##{id})"
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def trim_space(string)
|
23
|
+
string.to_s.split(newline).map(&:strip).reject(&:empty?).join('<br>')
|
24
|
+
end
|
25
|
+
|
26
|
+
def table(labels, rows)
|
27
|
+
TableFormatter.new.format(labels, rows)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Markdown
|
5
|
+
module Utility
|
6
|
+
class TableFormatter
|
7
|
+
include Core::Utility::CodeUtility
|
8
|
+
|
9
|
+
def format(labels, table)
|
10
|
+
code_block do |code|
|
11
|
+
build_md_lines(labels, table).each_with_index do |line, i|
|
12
|
+
code << nl if i.positive?
|
13
|
+
code << line
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def build_md_lines(labels, table)
|
21
|
+
lines = []
|
22
|
+
build_md_line(lines, labels)
|
23
|
+
build_md_line(lines, alignment_marks(labels.size))
|
24
|
+
table.each { |row| build_md_line(lines, row) }
|
25
|
+
lines
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_md_line(lines, row)
|
29
|
+
lines <<
|
30
|
+
['', *row]
|
31
|
+
.map(&method(:escape))
|
32
|
+
.zip(separators(row.size + 1))
|
33
|
+
.flatten
|
34
|
+
end
|
35
|
+
|
36
|
+
def escape(cell)
|
37
|
+
cell.to_s
|
38
|
+
.gsub('|', '|')
|
39
|
+
.gsub("\n", '<br>')
|
40
|
+
end
|
41
|
+
|
42
|
+
def separators(size)
|
43
|
+
Array.new(size, '|')
|
44
|
+
end
|
45
|
+
|
46
|
+
def alignment_marks(size)
|
47
|
+
Array.new(size, ':--')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rggen-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taichi Ishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.7'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.7'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ruport-wiki-table-formatter
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.2'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.2'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: bundler
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +26,7 @@ dependencies:
|
|
54
26
|
version: '0'
|
55
27
|
description: 'Markdown generator for RgGen.
|
56
28
|
|
57
|
-
'
|
29
|
+
'
|
58
30
|
email:
|
59
31
|
- rggen@googlegroups.com
|
60
32
|
executables: []
|
@@ -74,6 +46,7 @@ files:
|
|
74
46
|
- lib/rggen/markdown/setup.rb
|
75
47
|
- lib/rggen/markdown/utility.rb
|
76
48
|
- lib/rggen/markdown/utility/source_file.rb
|
49
|
+
- lib/rggen/markdown/utility/table_formatter.rb
|
77
50
|
- lib/rggen/markdown/version.rb
|
78
51
|
homepage: https://github.com/rggen/rggen-markdown
|
79
52
|
licenses:
|
@@ -91,15 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
64
|
requirements:
|
92
65
|
- - ">="
|
93
66
|
- !ruby/object:Gem::Version
|
94
|
-
version: '2.
|
67
|
+
version: '2.4'
|
95
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
69
|
requirements:
|
97
70
|
- - ">="
|
98
71
|
- !ruby/object:Gem::Version
|
99
72
|
version: '0'
|
100
73
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.1.2
|
102
75
|
signing_key:
|
103
76
|
specification_version: 4
|
104
|
-
summary: rggen-markdown-0.
|
77
|
+
summary: rggen-markdown-0.18.0
|
105
78
|
test_files: []
|