neo4j-asciidoctor-extensions 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f56c5e2f8d13065832c148fb4b3724e45a2542a19062b77953b92235e675010c
4
- data.tar.gz: 3129172a1921f8fb0fd666e36dff542255b5b797c5c6b68278cff728dabca7cb
3
+ metadata.gz: b9aa5c3d1385aa9d4dd4ac11820ffb24ab9dca9fd02b99bcffe6979031469adc
4
+ data.tar.gz: 129476850c9147c0fbc8accaf0309f59c787f2e4defb8a3c5ecd444a28060086
5
5
  SHA512:
6
- metadata.gz: 4a348aefd8422a543a9608907e3861386078ed6004715bbd0fac40f323c856c2d30925dc43b2a7d2d5086a34b8e8fa31475248fd7b02b628a6ab051e0a943fc4
7
- data.tar.gz: 7abdf4c55bab07472dc5b50f8e4891bf7555d07626d6ae0152a34d92e07f641101a95952169276de95e3994a2638d6315f0df332d6ad2530a2ad6dcc7a51ea81
6
+ metadata.gz: 6f0c5596adbf742abb16103642445284bb0be42720e1ed57fdc1f9cfa7322c0191261af133f2ae0c9a556696e0af2406e11157d935e5667c52793194101afe45
7
+ data.tar.gz: c0640a5f5a47220d006bcc2d84aca356dfdcadfb17554b1f121df9cb0aa2c81085566d0a946a8eab1842a36eda39a63b594802ce125522ad45a16062fe8f3986
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neo4j-asciidoctor-extensions (0.0.4)
4
+ neo4j-asciidoctor-extensions (0.0.5)
5
5
  asciidoctor (~> 2.0.0)
6
6
  asciidoctor-pdf (= 1.5.3)
7
7
  rouge (~> 3.18.0)
data/README.adoc CHANGED
@@ -1,4 +1,5 @@
1
1
  = Neo4j Asciidoctor Extensions
2
+ :caution-caption: :fire:
2
3
  :uri-neo4j: https://neo4j.com
3
4
 
4
5
  image:https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions/workflows/CI/badge.svg[CI,link=https://github.com/neo4j-contrib/neo4j-asciidoctor-extensions/actions?query=workflow%3ACI]
@@ -41,15 +42,30 @@ See below for the complete list of extensions.
41
42
 
42
43
  The Ruby gem contains 6 distinct extensions:
43
44
 
44
- === `course_document_attributes`
45
+ === Neo4j course attributes
45
46
 
46
- A postprocessor that adds attributes about the course.
47
+ A postprocessor that adds attributes about a course on the `Document`.
47
48
 
48
- === `cypher_syntax_role`
49
+ [CAUTION]
50
+ ====
51
+ This extension is tightly coupled to the course publishing project and should not be used for other purposes
52
+ ====
53
+
54
+ [source,rb]
55
+ ----
56
+ require 'neo4j/asciidoctor/extensions/course_document_attributes'
57
+ ----
58
+
59
+ === Cypher syntax role
49
60
 
50
61
  A tree processor that adds a role on code blocks using "cypher-syntax" as a language.
51
62
 
52
- *Usage:*
63
+ ==== Usage
64
+
65
+ [source,rb]
66
+ ----
67
+ require 'neo4j/asciidoctor/extensions/cypher_syntax_role'
68
+ ----
53
69
 
54
70
  [source]
55
71
  ....
@@ -62,11 +78,16 @@ A tree processor that adds a role on code blocks using "cypher-syntax" as a lang
62
78
  ----
63
79
  ....
64
80
 
65
- === `document_metadata_generator`
81
+ === Metadata generator (YAML)
66
82
 
67
83
  A postprocess that generates a metadata file (in YAML format) from a list of document attributes.
68
84
 
69
- *Usage:*
85
+ ==== Usage
86
+
87
+ [source,rb]
88
+ ----
89
+ require 'neo4j/asciidoctor/extensions/document_metadata_generator'
90
+ ----
70
91
 
71
92
  .file.adoc
72
93
  [source,adoc]
@@ -79,7 +100,7 @@ A postprocess that generates a metadata file (in YAML format) from a list of doc
79
100
  ----
80
101
 
81
102
  .file.yml
82
- [source,adoc]
103
+ [source,yaml]
83
104
  ----
84
105
  slug: intro-neo4j-4-0
85
106
  parent_path: /intro
@@ -104,12 +125,17 @@ taxonomies:
104
125
  - 3-6
105
126
  ----
106
127
 
107
- === `inline_highlighter_rouge`
128
+ === Inline syntax highlighter based on Rouge
108
129
 
109
130
  Inline syntax highlighter based on Rouge.
110
131
  It applies syntax highlighting on both monospaced text cypher and `src` inline macro:
111
132
 
112
- *Usage:*
133
+ ==== Usage
134
+
135
+ [source,rb]
136
+ ----
137
+ require 'neo4j/asciidoctor/extensions/inline_highlighter_rouge'
138
+ ----
113
139
 
114
140
  [source,adoc]
115
141
  ----
@@ -118,16 +144,29 @@ It applies syntax highlighting on both monospaced text cypher and `src` inline m
118
144
  src:cypher[MATCH (c:Customer {customerName: 'ABCCO'}) RETURN c.BOUGHT.productName]
119
145
  ----
120
146
 
121
- === `revealjs_linear_navigation`
147
+ === Linear navigation for reveal.js
122
148
 
123
149
  A tree process that "flatten" a reveal.js presentation to use a linear navigation.
124
150
  By default, the reveal.js converter will use a vertical navigation for the second levels of section titles (and below).
125
151
  This extension will effectively prevent that by using only first level section titles.
126
152
 
127
- === `revealjs_speaker_notes_aggregator`
153
+ ==== Usage
154
+
155
+ [source,rb]
156
+ ----
157
+ require 'neo4j/asciidoctor/extensions/revealjs_linear_navigation'
158
+ ----
159
+
160
+ === Notes aggregator for reveal.js
161
+
128
162
  A tree processor that aggregates multiple `[.notes]` blocks in a section (slide).
129
163
 
130
- *Usage:*
164
+ ==== Usage
165
+
166
+ [source,rb]
167
+ ----
168
+ require 'neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator'
169
+ ----
131
170
 
132
171
  [source,adoc]
133
172
  ----
@@ -146,6 +185,34 @@ This is another speaker note.
146
185
  --
147
186
  ----
148
187
 
188
+ === Document attribute update
189
+
190
+ A tree processor that update an attribute depending on a given rule.
191
+
192
+ ==== Usage
193
+
194
+ In the example below, we update the value of the `slug` attribute depending on the `stage` attribute:
195
+ [source,rb]
196
+ ----
197
+ require 'asciidoctor/extensions'
198
+ require 'neo4j/asciidoctor/extensions/attribute_update/extension'
199
+
200
+ Asciidoctor::Extensions.register do
201
+ ext = Neo4j::AsciidoctorExtensions::AttributeUpdateTreeProcessor
202
+ tree_processor ext.new attr_name: 'slug',
203
+ update_rule: lambda { |document, value|
204
+ case document.attr('stage')
205
+ when 'production'
206
+ value
207
+ when 'development'
208
+ "_dev_#{value}"
209
+ else
210
+ "_test_#{value}"
211
+ end
212
+ }
213
+ end
214
+ ----
215
+
149
216
  == Release
150
217
 
151
218
  The release process is automated and relies on GitHub Actions.
@@ -6,3 +6,4 @@ require_relative 'extensions/document_metadata_generator'
6
6
  require_relative 'extensions/inline_highlighter_rouge'
7
7
  require_relative 'extensions/revealjs_linear_navigation'
8
8
  require_relative 'extensions/revealjs_speaker_notes_aggregator'
9
+ require_relative 'extensions/stage_slug'
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
4
+
5
+ module Neo4j
6
+ # Asciidoctor extensions by Neo4j
7
+ module AsciidoctorExtensions
8
+ include Asciidoctor
9
+
10
+ # A tree processor that update an attribute depending on a given rule.
11
+ #
12
+ class AttributeUpdateTreeProcessor < Extensions::TreeProcessor
13
+ use_dsl
14
+
15
+ def process(document)
16
+ if (attribute_name = @config[:attr_name]) &&
17
+ (current_value = document.attr attribute_name) &&
18
+ (update_rule = @config[:update_rule])
19
+ new_value = update_rule.call(document, current_value)
20
+ document.set_attr attribute_name, new_value if new_value != current_value
21
+ end
22
+ document
23
+ end
24
+ end
25
+
26
+ # A tree processor that update the "slug" attribute depending on the "stage" attribute.
27
+ #
28
+ class StageSlugTreeProcessor < AttributeUpdateTreeProcessor
29
+ TESTING_SLUG_PREFIX = '_testing_'
30
+
31
+ def initialize(config = nil)
32
+ super
33
+ @config[:attr_name] = 'slug'
34
+ @config[:update_rule] = lambda { |document, value|
35
+ case document.attr('stage')
36
+ when 'production'
37
+ value
38
+ else
39
+ "#{TESTING_SLUG_PREFIX}#{value}"
40
+ end
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
4
+ require_relative 'attribute_update/extension'
5
+
6
+ Asciidoctor::Extensions.register do
7
+ tree_processor Neo4j::AsciidoctorExtensions::StageSlugTreeProcessor
8
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'neo4j-asciidoctor-extensions'
5
- s.version = '0.0.4'
5
+ s.version = '0.0.5'
6
6
  s.summary = 'Asciidoctor extensions by Neo4j.'
7
7
  s.description = 'Asciidoctor extensions by Neo4j.'
8
8
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'asciidoctor'
4
+ require 'asciidoctor/extensions'
5
+ require_relative '../lib/neo4j/asciidoctor/extensions/attribute_update/extension'
6
+
7
+ describe Neo4j::AsciidoctorExtensions::StageSlugTreeProcessor do
8
+ context 'convert to html5' do
9
+ it 'should update slug' do
10
+ registry = Asciidoctor::Extensions.create
11
+ registry.tree_processor Neo4j::AsciidoctorExtensions::StageSlugTreeProcessor
12
+ input = <<~'ADOC'
13
+ = Introduction to Neo4j 4.0
14
+ :slug: intro-neo4j-4-0
15
+
16
+ {slug}
17
+ ADOC
18
+ output = Asciidoctor.convert(input, extension_registry: registry, standalone: false, doctype: 'inline')
19
+ (expect output).to eql '_testing_intro-neo4j-4-0'
20
+ end
21
+ it 'should not update slug' do
22
+ registry = Asciidoctor::Extensions.create
23
+ registry.tree_processor Neo4j::AsciidoctorExtensions::StageSlugTreeProcessor
24
+ input = <<~'ADOC'
25
+ = Introduction to Neo4j 4.0
26
+ :stage: production
27
+ :slug: intro-neo4j-4-0
28
+
29
+ {slug}
30
+ ADOC
31
+ output = Asciidoctor.convert(input, extension_registry: registry, standalone: false, doctype: 'inline')
32
+ (expect output).to eql 'intro-neo4j-4-0'
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-asciidoctor-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Grossetie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2020-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -127,6 +127,7 @@ files:
127
127
  - README.adoc
128
128
  - Rakefile
129
129
  - lib/neo4j/asciidoctor/extensions.rb
130
+ - lib/neo4j/asciidoctor/extensions/attribute_update/extension.rb
130
131
  - lib/neo4j/asciidoctor/extensions/course_document_attributes.rb
131
132
  - lib/neo4j/asciidoctor/extensions/course_document_attributes/extension.rb
132
133
  - lib/neo4j/asciidoctor/extensions/cypher_syntax_role.rb
@@ -139,6 +140,7 @@ files:
139
140
  - lib/neo4j/asciidoctor/extensions/revealjs_linear_navigation/extension.rb
140
141
  - lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator.rb
141
142
  - lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator/extension.rb
143
+ - lib/neo4j/asciidoctor/extensions/stage_slug.rb
142
144
  - neo4j-asciidoctor-extensions.gemspec
143
145
  - spec/.rubocop.yml
144
146
  - spec/cypher_syntax_role_spec.rb
@@ -146,6 +148,7 @@ files:
146
148
  - spec/inline_highlighter_rouge_spec.rb
147
149
  - spec/revealjs_linear_navigation_spec.rb
148
150
  - spec/revealjs_speaker_notes_aggregator_spec.rb
151
+ - spec/stage_slug_spec.rb
149
152
  - tasks/bundler.rake
150
153
  - tasks/lint.rake
151
154
  - tasks/rspec.rake
@@ -181,3 +184,4 @@ test_files:
181
184
  - spec/inline_highlighter_rouge_spec.rb
182
185
  - spec/revealjs_linear_navigation_spec.rb
183
186
  - spec/revealjs_speaker_notes_aggregator_spec.rb
187
+ - spec/stage_slug_spec.rb