asciidoc-pubkit 0.6.1 → 0.6.3
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
- data/CHANGELOG.md +37 -11
- data/README.md +424 -51
- data/data/heading-rules.ja.yml +23 -0
- data/data/writing/ja/headings.md +45 -0
- data/lib/asciidoc_pubkit/cli.rb +9 -3
- data/lib/asciidoc_pubkit/document.rb +56 -4
- data/lib/asciidoc_pubkit/heading_rules.rb +88 -0
- data/lib/asciidoc_pubkit/rules.rb +50 -12
- data/lib/asciidoc_pubkit/session.rb +117 -11
- data/lib/asciidoc_pubkit/settings.rb +15 -3
- data/lib/asciidoc_pubkit/writing.rb +5 -0
- data/lib/asciidoc_pubkit.rb +2 -1
- metadata +6 -3
|
@@ -23,16 +23,28 @@ module AsciidocPubkit
|
|
|
23
23
|
reject_keys(config, ['review'], 'configuration')
|
|
24
24
|
review = config.fetch('review', {})
|
|
25
25
|
raise Error, 'review must be a mapping.' unless review.is_a?(Hash)
|
|
26
|
-
reject_keys(review, %w[language style glossary exclude allows attributes base_dir tokenizer mecab_command mecab_dictionary rules], 'review')
|
|
26
|
+
reject_keys(review, %w[language style glossary exclude allows attributes base_dir tokenizer mecab_command mecab_dictionary rules heading_rules], 'review')
|
|
27
27
|
raise Error, 'attributes must be a mapping.' unless review.fetch('attributes', {}).is_a?(Hash)
|
|
28
|
-
%w[base_dir glossary mecab_command mecab_dictionary rules].each do |key|
|
|
28
|
+
%w[base_dir glossary mecab_command mecab_dictionary rules heading_rules].each do |key|
|
|
29
29
|
raise Error, "#{key} must be a nonempty path string." if review.key?(key) && (!review[key].is_a?(String) || review[key].empty?)
|
|
30
30
|
end
|
|
31
31
|
base = @path ? File.dirname(@path) : File.dirname(File.expand_path(entry))
|
|
32
32
|
language = Language.validate!(options[:language] || review.fetch('language', Language::DEFAULT), operation: 'review')
|
|
33
|
+
scope = options.fetch(:scope, 'prose')
|
|
34
|
+
raise Error, 'scope must be prose or headings.' unless %w[prose headings].include?(scope)
|
|
35
|
+
if scope == 'headings' && (options[:rules] || options[:style])
|
|
36
|
+
raise Error, 'Heading scans use --heading-rules, not prose --rules or --style.'
|
|
37
|
+
end
|
|
38
|
+
if scope == 'prose' && options[:heading_rules]
|
|
39
|
+
raise Error, '--heading-rules requires --scope headings.'
|
|
40
|
+
end
|
|
41
|
+
heading_rules_path = options[:heading_rules] ? File.expand_path(options[:heading_rules]) : (review['heading_rules'] ? File.expand_path(review['heading_rules'], base) : HeadingRuleSet.default_path(language))
|
|
33
42
|
rules_path = options[:rules] ? File.expand_path(options[:rules]) : (review['rules'] ? File.expand_path(review['rules'], base) : RuleSet.default_path(language))
|
|
34
43
|
@data = {
|
|
35
|
-
'
|
|
44
|
+
'scope' => scope,
|
|
45
|
+
'heading_rules' => scope == 'headings' ? HeadingRuleSet.load(heading_rules_path) : nil,
|
|
46
|
+
'heading_rules_path' => heading_rules_path,
|
|
47
|
+
'rules' => scope == 'prose' ? RuleSet.load(rules_path) : nil,
|
|
36
48
|
'rules_path' => rules_path,
|
|
37
49
|
'language' => language,
|
|
38
50
|
'style' => options[:style] || review.fetch('style', 'preserve'),
|
|
@@ -13,6 +13,11 @@ module AsciidocPubkit
|
|
|
13
13
|
criteria(language).sub(/\A# [^\n]+\n\n/, '').gsub(/^## /, '### ')
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def self.heading_criteria(language = Language::DEFAULT)
|
|
17
|
+
Language.validate!(language, operation: 'review')
|
|
18
|
+
AsciidocPubkit.read_text(File.join(DATA_ROOT, language, 'headings.md'))
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
def self.prompt(language = Language::DEFAULT)
|
|
17
22
|
guide = prompt_criteria(language)
|
|
18
23
|
<<~TEXT
|
data/lib/asciidoc_pubkit.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'pathname'
|
|
|
9
9
|
require 'optparse'
|
|
10
10
|
|
|
11
11
|
module AsciidocPubkit
|
|
12
|
-
VERSION = '0.6.
|
|
12
|
+
VERSION = '0.6.3'
|
|
13
13
|
class Error < StandardError; end
|
|
14
14
|
|
|
15
15
|
def self.hash_text(text)
|
|
@@ -26,6 +26,7 @@ end
|
|
|
26
26
|
require_relative 'asciidoc_pubkit/language'
|
|
27
27
|
require_relative 'asciidoc_pubkit/writing'
|
|
28
28
|
require_relative 'asciidoc_pubkit/rule_set'
|
|
29
|
+
require_relative 'asciidoc_pubkit/heading_rules'
|
|
29
30
|
require_relative 'asciidoc_pubkit/settings'
|
|
30
31
|
require_relative 'asciidoc_pubkit/document'
|
|
31
32
|
require_relative 'asciidoc_pubkit/morphology'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asciidoc-pubkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CyberGarage
|
|
@@ -37,8 +37,8 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '1.0'
|
|
40
|
-
description: Generate Japanese technical writing prompts, review AsciiDoc prose
|
|
41
|
-
verify protected manuscript content.
|
|
40
|
+
description: Generate Japanese technical writing prompts, review AsciiDoc prose and
|
|
41
|
+
section headings separately, and verify protected manuscript content.
|
|
42
42
|
executables:
|
|
43
43
|
- asciidoc-pubkit
|
|
44
44
|
extensions: []
|
|
@@ -47,13 +47,16 @@ files:
|
|
|
47
47
|
- CHANGELOG.md
|
|
48
48
|
- LICENSE
|
|
49
49
|
- README.md
|
|
50
|
+
- data/heading-rules.ja.yml
|
|
50
51
|
- data/review-rules.ja.yml
|
|
51
52
|
- data/writing/ja/criteria.md
|
|
53
|
+
- data/writing/ja/headings.md
|
|
52
54
|
- examples/book.adoc
|
|
53
55
|
- exe/asciidoc-pubkit
|
|
54
56
|
- lib/asciidoc_pubkit.rb
|
|
55
57
|
- lib/asciidoc_pubkit/cli.rb
|
|
56
58
|
- lib/asciidoc_pubkit/document.rb
|
|
59
|
+
- lib/asciidoc_pubkit/heading_rules.rb
|
|
57
60
|
- lib/asciidoc_pubkit/language.rb
|
|
58
61
|
- lib/asciidoc_pubkit/local_evaluator.rb
|
|
59
62
|
- lib/asciidoc_pubkit/morphology.rb
|