prawn-dev 0.3.0 → 0.5.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/prawn/dev/tasks.rb +43 -4
- data/lib/prawn/dev/version.rb +1 -1
- data/lib/prawn/dev/yard_markup/code_highlight.rb +30 -0
- data/lib/prawn/dev/yard_markup/document.rb +50 -0
- data/lib/prawn/dev/yard_markup.rb +16 -0
- data/lib/rubocop/cop/prawn/style/trailing_comma_fix.rb +19 -0
- data/lib/rubocop/cop/prawn_cops.rb +18 -0
- data/rubocop.yml +476 -72
- data/templates/default/fulldoc/html/css/style.css +1021 -0
- data/templates/default/fulldoc/html/js/app.js +317 -0
- data/templates/default/fulldoc/html/setup.rb +19 -0
- data/templates/default/layout/html/setup.rb +14 -0
- data/templates/default/method_details/html/source.erb +17 -0
- data/templates/default/module/html/attribute_summary.erb +11 -0
- data/templates/default/module/html/constant_summary.erb +20 -0
- data/templates/default/module/html/item_summary.erb +46 -0
- data/templates/default/module/html/method_summary.erb +17 -0
- data/templates/default/tags/html/example.erb +11 -0
- data.tar.gz.sig +0 -0
- metadata +97 -29
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59a3474b2e4134fb8a6ee6d9d8b319fe1f8163a0dc17da1829fb595210cbecb5
|
4
|
+
data.tar.gz: 3a8e7895c7d880136b8c5553f16a3fcde1c1d6e2b3b34f10c93ab1ac3e688b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daf56294f1bde9d63c121ae4862273dd85bf26cea3e137f4047a85996529f65fa4c45dea7de42d9c2e8758eeea14f3a8aa526a67940ae91551281fa6b81709c1
|
7
|
+
data.tar.gz: f3eecf76613027b9815d1b9d5adf95cfe7acc9a2ca06189b71a1d0a4c5144029695b0567c12dd09692b106bc6a12589ff3838bbe1d23f6749002eb11a8146030
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/prawn/dev/tasks.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
3
4
|
require 'rubygems/package_task'
|
4
5
|
|
5
|
-
unless Kernel.const_defined?(
|
6
|
+
unless Kernel.const_defined?(:GEMSPEC)
|
6
7
|
raise StandardError, 'GEMSPEC is not defined'
|
7
8
|
end
|
8
9
|
|
@@ -10,7 +11,7 @@ package_task = Gem::PackageTask.new(Gem::Specification.load(GEMSPEC))
|
|
10
11
|
package_task.define
|
11
12
|
|
12
13
|
built_gem_path = "pkg/#{package_task.package_name}.gem"
|
13
|
-
checksum_path = "checksums/#{File.basename
|
14
|
+
checksum_path = "checksums/#{File.basename(built_gem_path)}.sha512"
|
14
15
|
|
15
16
|
file built_gem_path do
|
16
17
|
Rake::Task['package'].invoke
|
@@ -19,7 +20,7 @@ end
|
|
19
20
|
file checksum_path => built_gem_path do
|
20
21
|
require 'digest/sha2'
|
21
22
|
checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
|
22
|
-
|
23
|
+
FileUtils.mkdir_p('checksums')
|
23
24
|
File.write(checksum_path, checksum)
|
24
25
|
end
|
25
26
|
|
@@ -35,12 +36,50 @@ RSpec::Core::RakeTask.new('spec') do |c|
|
|
35
36
|
end
|
36
37
|
|
37
38
|
require 'yard'
|
39
|
+
YARD_OPTIONS = [
|
40
|
+
'--output-dir', 'doc/html',
|
41
|
+
'--verbose', '--debug',
|
42
|
+
'--load', File.expand_path('yard_markup.rb', __dir__),
|
43
|
+
'--markup', 'markdown',
|
44
|
+
'--markup-provider', 'prawn/dev/yard_markup/document',
|
45
|
+
'--use-cache',
|
46
|
+
].freeze
|
38
47
|
|
39
48
|
YARD::Rake::YardocTask.new do |t|
|
40
|
-
t.options =
|
49
|
+
t.options = YARD_OPTIONS + t.options
|
50
|
+
t.stats_options = ['--list-undoc', '--compact']
|
41
51
|
end
|
42
52
|
task docs: :yard
|
43
53
|
|
54
|
+
require 'fileutils'
|
55
|
+
def stash_yardopts
|
56
|
+
if File.exist?('.yardopts')
|
57
|
+
begin
|
58
|
+
original_opts = Shellwords.shellsplit(File.read('.yardopts'))
|
59
|
+
require('securerandom')
|
60
|
+
backup_file = ".yardopts-#{SecureRandom.alphanumeric(16)}.backup"
|
61
|
+
FileUtils.move('.yardopts', backup_file)
|
62
|
+
yield original_opts
|
63
|
+
ensure
|
64
|
+
FileUtils.move(backup_file, '.yardopts')
|
65
|
+
end
|
66
|
+
else
|
67
|
+
yield []
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Generate YARD Documentation continuously'
|
72
|
+
task :yard_watch do
|
73
|
+
yard_server = YARD::CLI::Server.new
|
74
|
+
stash_yardopts do |original_opts|
|
75
|
+
File.open('.yardopts', 'w') do |yardopts|
|
76
|
+
yardopts.write((YARD_OPTIONS + original_opts).shelljoin)
|
77
|
+
yardopts.fsync
|
78
|
+
yard_server.run('--reload')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
44
83
|
require 'rubocop/rake_task'
|
45
84
|
|
46
85
|
RuboCop::RakeTask.new
|
data/lib/prawn/dev/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kramdown'
|
4
|
+
require 'rouge'
|
5
|
+
|
6
|
+
module Prawn
|
7
|
+
module Dev
|
8
|
+
module YardMarkup
|
9
|
+
module CodeHighlight
|
10
|
+
def html_syntax_highlight_ruby(source)
|
11
|
+
converter =
|
12
|
+
Kramdown::Converter::Html.__send__(
|
13
|
+
:new,
|
14
|
+
nil,
|
15
|
+
Prawn::Dev::YardMarkup::Document.new('').default_options,
|
16
|
+
)
|
17
|
+
|
18
|
+
el = Kramdown::Element.new(:codeblock, source, { lang: 'ruby' })
|
19
|
+
converter.convert(el, 0)
|
20
|
+
end
|
21
|
+
alias html_markup_ruby html_syntax_highlight_ruby
|
22
|
+
|
23
|
+
# Do nothing
|
24
|
+
def parse_codeblocks(html)
|
25
|
+
html
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kramdown'
|
4
|
+
require 'kramdown-parser-gfm'
|
5
|
+
require 'rouge'
|
6
|
+
|
7
|
+
module Prawn
|
8
|
+
module Dev
|
9
|
+
module YardMarkup
|
10
|
+
class CodeFormatter < ::Rouge::Formatter
|
11
|
+
def initialize(opts = {})
|
12
|
+
super
|
13
|
+
|
14
|
+
@opts = opts
|
15
|
+
@formatter =
|
16
|
+
if opts[:inline_theme]
|
17
|
+
::Rouge::Formatters::HTMLInline.new(opts[:inline_theme])
|
18
|
+
else
|
19
|
+
::Rouge::Formatters::HTML.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def stream(tokens, &block)
|
24
|
+
yield %(<pre><code>) unless @opts[:inline]
|
25
|
+
@formatter.stream(tokens, &block)
|
26
|
+
yield '</code></pre>' unless @opts[:inline]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Document < Kramdown::Document
|
31
|
+
def initialize(source, options = {})
|
32
|
+
super(source, default_options.merge(options))
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_options
|
36
|
+
{
|
37
|
+
input: 'GFM',
|
38
|
+
hard_wrap: false,
|
39
|
+
syntax_highlighter: :rouge,
|
40
|
+
syntax_highlighter_opts: {
|
41
|
+
default_lang: 'ruby',
|
42
|
+
block: { formatter: CodeFormatter },
|
43
|
+
span: { formatter: CodeFormatter, inline: true },
|
44
|
+
},
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'yard_markup/code_highlight'
|
4
|
+
|
5
|
+
module Prawn
|
6
|
+
module Dev
|
7
|
+
module YardMarkup
|
8
|
+
YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown].push(
|
9
|
+
{ lib: :'prawn/dev/yard_markup/document', const: 'Prawn::Dev::YardMarkup::Document' },
|
10
|
+
)
|
11
|
+
YARD::Templates::Engine.register_template_path(File.expand_path('../../../templates', __dir__))
|
12
|
+
|
13
|
+
YARD::Templates::Helpers::HtmlHelper.prepend(Prawn::Dev::YardMarkup::CodeHighlight)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Prawn
|
6
|
+
module Style
|
7
|
+
module TrailingCommaFix
|
8
|
+
def should_have_comma?(style, node)
|
9
|
+
if style == :prawn_comma
|
10
|
+
node.loc.begin.line != node.loc.end.line # parens are on different lines
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
require_relative 'prawn/style/trailing_comma_fix'
|
5
|
+
|
6
|
+
RuboCop::Cop::Style::TrailingCommaInArguments.prepend(RuboCop::Cop::Prawn::Style::TrailingCommaFix)
|
7
|
+
RuboCop::Cop::Style::TrailingCommaInArrayLiteral.prepend(RuboCop::Cop::Prawn::Style::TrailingCommaFix)
|
8
|
+
RuboCop::Cop::Style::TrailingCommaInBlockArgs.prepend(RuboCop::Cop::Prawn::Style::TrailingCommaFix)
|
9
|
+
RuboCop::Cop::Style::TrailingCommaInHashLiteral.prepend(RuboCop::Cop::Prawn::Style::TrailingCommaFix)
|
10
|
+
|
11
|
+
%w[
|
12
|
+
Style/TrailingCommaInArguments
|
13
|
+
Style/TrailingCommaInArrayLiteral
|
14
|
+
Style/TrailingCommaInBlockArgs
|
15
|
+
Style/TrailingCommaInHashLiteral
|
16
|
+
].each do |cop_name|
|
17
|
+
RuboCop::ConfigLoader.default_configuration[cop_name]['SupportedStylesForMultiline']&.append('prawn_comma')
|
18
|
+
end
|