neo4j-asciidoctor-extensions 0.1.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcbc65f6a14ef93402a8961fb7bac6edfcbf20a62c456bde6bf8bf925afdd7a6
4
- data.tar.gz: 3f3144432df9404adfa853e72fe45f6a333240e270f5d81f6f022776144d95e7
3
+ metadata.gz: bad2d6a6b8a6c047e68d9710bd3b4be2a2e998bc67ae07fa6aba02bde1f6da8c
4
+ data.tar.gz: 9971ece22eec20c0a58c4b07511eb5a1ce8198bff44ec7323a592e355ba64259
5
5
  SHA512:
6
- metadata.gz: 63cf0561afd28054eddca4cf0139d2c75dd26afa056dea387e00237f03e82bfdc2ab99e7c0efe9d5ecf2dabf78c1138a8c5703f6fe82733aca59762df472c29d
7
- data.tar.gz: 995c16ae55d5c2a9636781298bd241f2db04b8040549ee36d83015955b36b6badd21ff59e13da39e2a0af7ada70961538f5f53a780cdd92d3c4238010e4fc698
6
+ metadata.gz: af95705de0987a1906cf66f23b8b33f655bd541fc689fe8a11a1193a0d4703762cd846aa67d916c5accc35277732f4b528831230f21c3ecde19df5057f22d4cf
7
+ data.tar.gz: 52e77d769e05f863c78910fa551323ebfcaf249ede0fa90683aa8d1bf839e3f8b82f41bdd3e72bbde7948ae8ba9ef36622adb92498e09249078aa38c15958015
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neo4j-asciidoctor-extensions (0.1.0)
5
- asciidoctor (~> 2.0.0)
4
+ neo4j-asciidoctor-extensions (0.3.1)
5
+ asciidoctor (~> 2.0)
6
6
  asciidoctor-pdf (= 1.5.3)
7
- rouge (~> 3.18.0)
7
+ rouge (~> 3.18)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -3,6 +3,7 @@
3
3
  :uri-neo4j: https://neo4j.com
4
4
 
5
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]
6
+ image:https://badge.fury.io/rb/neo4j-asciidoctor-extensions.svg["Gem Version", link="https://rubygems.org/gems/neo4j-asciidoctor-extensions"]
6
7
 
7
8
  This repository contains Asciidoctor extensions made by {uri-neo4j}[Neo4j] for processing and publishing AsciiDoc content.
8
9
 
@@ -17,18 +17,16 @@ module Neo4j
17
17
  TESTING_SLUG_PREFIX = '_testing_'
18
18
 
19
19
  def process(document)
20
- if (docdir = document.attr 'docdir')
21
- # TODO: this path should be configurable
22
- path = File.expand_path('../build/online/asciidoctor-module-descriptor.yml', docdir)
23
- if File.exist?(path)
20
+ if (module_descriptor_path = document.attr('module-descriptor-path'))
21
+ if File.exist?(module_descriptor_path)
24
22
  require 'yaml'
25
- module_descriptor = YAML.load_file(path)
26
- if (document_slug = document.attr 'slug') && document.attr('stage') != 'production'
23
+ module_descriptor = YAML.load_file(module_descriptor_path)
24
+ if (document_slug = document.attr('slug')) && document.attr('stage') != 'production'
27
25
  document_slug = "#{TESTING_SLUG_PREFIX}#{document_slug}"
28
- document.set_attr 'slug', document_slug
26
+ document.set_attr('slug', document_slug)
29
27
  end
30
28
  set_attributes(document, document_slug, module_descriptor)
31
- document.set_attribute 'module-name', module_descriptor['module_name']
29
+ document.set_attribute('module-name', module_descriptor['module_name'])
32
30
  end
33
31
  end
34
32
  document
@@ -38,17 +36,17 @@ module Neo4j
38
36
 
39
37
  def set_attributes(document, document_slug, module_descriptor)
40
38
  module_descriptor['pages'].each_with_index do |page, index|
41
- document.set_attribute "module-toc-link-#{index}", page['url']
42
- document.set_attribute "module-toc-title-#{index}", page['title']
39
+ document.set_attribute("module-toc-link-#{index}", page['url'])
40
+ document.set_attribute("module-toc-title-#{index}", page['title'])
43
41
  page_slug = page['slug']
44
42
  page_slug = "#{TESTING_SLUG_PREFIX}#{page_slug}" unless document.attr('stage') == 'production'
45
- document.set_attribute "module-toc-slug-#{index}", page_slug
46
- document.set_attribute "module-quiz-#{index}", page['quiz']
43
+ document.set_attribute("module-toc-slug-#{index}", page_slug)
44
+ document.set_attribute("module-quiz-#{index}", page['quiz'])
47
45
  next unless document_slug == page_slug
48
46
 
49
47
  set_next_attributes(document, page)
50
- document.set_attribute 'module-quiz', page['quiz']
51
- document.set_attribute 'module-certificate', page['certificate']
48
+ document.set_attribute('module-quiz', page['quiz'])
49
+ document.set_attribute('module-certificate', page['certificate'])
52
50
  end
53
51
  end
54
52
 
@@ -57,8 +55,8 @@ module Neo4j
57
55
 
58
56
  next_page_slug = page['next']['slug']
59
57
  next_page_slug = "#{TESTING_SLUG_PREFIX}#{next_page_slug}" unless document.attr('stage') == 'production'
60
- document.set_attr 'module-next-slug', next_page_slug, false
61
- document.set_attr 'module-next-title', page['next']['title'], false
58
+ document.set_attr('module-next-slug', next_page_slug, false)
59
+ document.set_attr('module-next-title', page['next']['title'], false)
62
60
  end
63
61
  end
64
62
  end
@@ -69,7 +69,7 @@ module Neo4j
69
69
  attr_name = resolve_attr_name(attr_include)
70
70
  if document.attr? attr_name
71
71
  attr_value = resolve_attribute_value(attr_name, document, value_type)
72
- metadata[attr_name] = attr_value
72
+ metadata[attr_name.gsub('-', '_')] = attr_value
73
73
  end
74
74
  end
75
75
  metadata['title'] = document.doctitle
@@ -96,7 +96,6 @@ module Neo4j
96
96
  .gsub(/\*$/, '')
97
97
  .gsub(/\*<>$/, '')
98
98
  .gsub(/\*<>$/, '')
99
- .gsub('-', '_')
100
99
  end
101
100
 
102
101
  def write(metadata, outfile)
@@ -119,7 +118,7 @@ module Neo4j
119
118
  split_values(attr_name, document)
120
119
  .map do |tuple|
121
120
  key, value = tuple.split('=')
122
- { 'key' => key.strip, 'values' => value.strip.split(';').map(&:strip).reject(&:empty?) }
121
+ { 'key' => key.strip, 'values' => (value && value.strip.split(';').map(&:strip).reject(&:empty?)) || [] }
123
122
  end
124
123
  else
125
124
  document.attr attr_name
@@ -0,0 +1,45 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ require 'rouge' unless defined? ::Rouge::Lexers
5
+
6
+ module Rouge
7
+ module Themes
8
+ #
9
+ # Neo4j (default) theme
10
+ class Neo < CSSTheme
11
+ name 'neo'
12
+
13
+ style Comment::Multiline,
14
+ Comment::Preproc,
15
+ Comment::Single,
16
+ Comment::Special,
17
+ Comment, fg: '#75787b'
18
+ style Error,
19
+ Generic::Error,
20
+ Generic::Traceback, fg: '#960050'
21
+ style Keyword::Constant,
22
+ Keyword::Declaration,
23
+ Keyword::Reserved,
24
+ Name::Constant,
25
+ Keyword::Type, fg: '#1d75b3'
26
+ style Literal::String, fg: '#b35e14'
27
+ style Name::Function,
28
+ Operator, fg: '#2e383c'
29
+ style Name::Namespace,
30
+ Name::Label,
31
+ Literal::String::Delimiter,
32
+ Name::Property, fg: '#75438a'
33
+ style Name::Entity,
34
+ Name::Builtin::Pseudo,
35
+ Name::Variable::Global,
36
+ Name::Variable::Instance,
37
+ Name::Variable,
38
+ Text::Whitespace,
39
+ Text,
40
+ Name, fg: '#047d65'
41
+ style Keyword, fg: '#1d75b3'
42
+ style Literal::String::Symbol, fg: '#9c3328'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ require 'rouge' unless defined? ::Rouge::Lexers
5
+
6
+ module Rouge
7
+ module Themes
8
+ #
9
+ # Neo4j forest theme
10
+ class NeoForest < CSSTheme
11
+ name 'neo.forest'
12
+
13
+ style Comment::Multiline,
14
+ Comment::Preproc,
15
+ Comment::Single,
16
+ Comment::Special,
17
+ Comment, fg: '#75787b'
18
+ style Error,
19
+ Generic::Error,
20
+ Generic::Traceback, fg: '#960050'
21
+ style Name::Function,
22
+ Operator::Word,
23
+ Keyword,
24
+ Keyword::Constant,
25
+ Keyword::Declaration,
26
+ Keyword::Reserved,
27
+ Name::Constant,
28
+ Keyword::Type, fg: '#859900'
29
+ style Literal::String, fg: '#b58900'
30
+ style Literal::Number, fg: '#2aa198'
31
+ style Operator,
32
+ Name::Namespace,
33
+ Name::Label,
34
+ Literal::String::Delimiter,
35
+ Name::Property,
36
+ Name::Entity,
37
+ Name::Builtin::Pseudo,
38
+ Name::Variable::Global,
39
+ Name::Variable::Instance,
40
+ Name::Variable,
41
+ Text::Whitespace,
42
+ Text,
43
+ Name,
44
+ Literal::String::Symbol, fg: '#333333'
45
+ end
46
+ end
47
+ 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.1.0'
5
+ s.version = '0.3.1'
6
6
  s.summary = 'Asciidoctor extensions by Neo4j.'
7
7
  s.description = 'Asciidoctor extensions by Neo4j.'
8
8
 
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_runtime_dependency 'asciidoctor', '~> 2.0.0'
21
+ s.add_runtime_dependency 'asciidoctor', '~> 2.0'
22
22
  s.add_runtime_dependency 'asciidoctor-pdf', '1.5.3'
23
- s.add_runtime_dependency 'rouge', '~> 3.18.0'
23
+ s.add_runtime_dependency 'rouge', '~> 3.18'
24
24
 
25
25
  s.add_development_dependency 'asciidoctor-revealjs', '~> 4.0'
26
26
  s.add_development_dependency 'rake', '~> 12.3.2'
@@ -115,5 +115,39 @@ describe Neo4j::AsciidoctorExtensions::DocumentMetadataGeneratorPostProcessor do
115
115
  expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'programming_language' }['values']).to eql(%w[java])
116
116
  expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'neo4j_version' }['values']).to eql(%w[3-5 3-6])
117
117
  end
118
+ it 'should replace - by _ in the attribute name' do
119
+ input = <<~'ADOC'
120
+ = Introduction to Neo4j 4.0
121
+ :slug: introduction-neo4j-4-0
122
+ :parent-path: /labs
123
+
124
+ This is a paragraph.
125
+ ADOC
126
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html', attributes: {
127
+ 'document-metadata-attrs-include' => 'slug,parent-path'
128
+ })
129
+ metadata = YAML.load_file('spec/output/test.yml')
130
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
131
+ expect(metadata['slug']).to eql('introduction-neo4j-4-0')
132
+ expect(metadata['parent_path']).to eql('/labs')
133
+ end
134
+ it 'should ignore empty value in taxonomies' do
135
+ input = <<~'ADOC'
136
+ = Introduction to Neo4j 4.0
137
+ :slug: introduction-neo4j-4-0
138
+ :taxonomies: neo4j_versions= , tags= intro ; neo4j;;
139
+
140
+ This is a paragraph.
141
+ ADOC
142
+ Asciidoctor.convert(input, safe: 'safe', to_file: 'spec/output/test.html', attributes: {
143
+ 'document-metadata-attrs-include' => 'slug,taxonomies*<>'
144
+ })
145
+ metadata = YAML.load_file('spec/output/test.yml')
146
+ expect(metadata['title']).to eql('Introduction to Neo4j 4.0')
147
+ expect(metadata['slug']).to eql('introduction-neo4j-4-0')
148
+ taxonomies = metadata['taxonomies']
149
+ expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'neo4j_versions' }['values']).to eql([])
150
+ expect(taxonomies.detect { |taxonomy| taxonomy['key'] == 'tags' }['values']).to eql(%w[intro neo4j])
151
+ end
118
152
  end
119
153
  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.1.0
4
+ version: 0.3.1
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-05-04 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: asciidoctor-pdf
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.18.0
47
+ version: '3.18'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.18.0
54
+ version: '3.18'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: asciidoctor-revealjs
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +141,8 @@ files:
141
141
  - lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator.rb
142
142
  - lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator/extension.rb
143
143
  - lib/neo4j/asciidoctor/extensions/stage_slug.rb
144
+ - lib/neo4j/rouge/themes/neo.rb
145
+ - lib/neo4j/rouge/themes/neo_forest.rb
144
146
  - neo4j-asciidoctor-extensions.gemspec
145
147
  - spec/.rubocop.yml
146
148
  - spec/cypher_syntax_role_spec.rb