jekyll-dyndoc 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll-dyndoc.rb +153 -0
  3. metadata +61 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dcc449b18530e0eec2da69b99e1b3b3a0c762b49
4
+ data.tar.gz: fdcd022c8eb664fbc0e301683b445f352ead029c
5
+ SHA512:
6
+ metadata.gz: e1fb5dd88a21f657ca50d4bf73aecdab147120e84ed9f564f864d60c2c689b49616d34172bf39cfd14e0985d661b18bcab999a6b1a2bb224d2a3a3e1bcf79b46
7
+ data.tar.gz: 312da2ecbb7b979f65724e198c580a46a07752bc6c0f0bb8e3ed1a9fd83c16c9afdb59d0c448b126ea7ce7f2793c2645c202b19f89b36964b8d0792ecf4ceaf3
@@ -0,0 +1,153 @@
1
+ JEKYLL_MIN_VERSION_3 = Gem::Version.new(Jekyll::VERSION) >= Gem::Version.new('3.0.0') unless defined? JEKYLL_MIN_VERSION_3
2
+
3
+ module Jekyll
4
+ module Converters
5
+ class DyndocConverter < Converter
6
+
7
+ safe true
8
+
9
+ def initialize(config)
10
+ @config = config
11
+ config['dyndoc'] ||= 'dyndoc-server'
12
+ dyndoc_ext = (config['dyndoc_ext'] ||= 'dyn')
13
+ config['dyndoc_ext_re'] = Regexp.new("\.(#{dyndoc_ext.tr ',', '|'})$", Regexp::IGNORECASE)
14
+ config['dyndoc_page_attribute_prefix'] ||= 'page'
15
+ # unless (dyndoc_config = (config['dyndoc'] ||= {})).frozen?
16
+ # # NOTE convert keys to symbols
17
+ # dyndoc_config.keys.each do |key|
18
+ # dyndoc_config[key.to_sym] = dyndoc_config.delete(key)
19
+ # end
20
+ # dyndoc_config[:safe] ||= 'safe'
21
+ # (dyndoc_config[:attributes] ||= []).tap do |attributes|
22
+ # attributes.unshift('notitle', 'hardbreaks', 'idprefix', 'idseparator=-', 'linkattrs')
23
+ # attributes.concat(IMPLICIT_ATTRIBUTES)
24
+ # end
25
+ # dyndoc_config.freeze
26
+ # end
27
+ end
28
+
29
+ def setup
30
+ return if @setup
31
+ @setup = true
32
+ case @config['dyndoc']
33
+ when 'dyndoc','dyndoc-server'
34
+ begin
35
+ require 'dyndoc-convert' unless defined? ::Dyndoc
36
+ rescue LoadError
37
+ STDERR.puts 'You are missing a library required to convert Dyndoc files. Please run:'
38
+ STDERR.puts ' $ [sudo] gem install dyndoc-ruby'
39
+ raise FatalException.new('Missing dependency: dyndoc')
40
+ end
41
+ else
42
+ STDERR.puts "Invalid Dyndoc processor: #{@config['dyndoc']}"
43
+ STDERR.puts ' Valid options are [ dyndoc ]'
44
+ raise FatalException.new("Invalid Dyndoc processor: #{@config['dyndoc']}")
45
+ end
46
+ end
47
+
48
+ def matches(ext)
49
+ ext =~ @config['dyndoc_ext_re']
50
+ end
51
+
52
+ def output_ext(ext)
53
+ '.html'
54
+ end
55
+
56
+ def convert(content)
57
+ setup
58
+ p [:config,@config]
59
+ case @config['dyndoc']
60
+ when 'dyndoc'
61
+ res=Dyndoc.convert(content, @config['dyndoc'])
62
+ p [:res,res]
63
+ res || ""
64
+ when 'dyndoc-server'
65
+ p [:content,content]
66
+ res=Dyndoc.cli_convert(content, @config['dyndoc'])
67
+ p [:res,res]
68
+ res || ""
69
+ else
70
+ warn 'Unknown Dyndoc converter. Passing through raw content.'
71
+ content
72
+ end
73
+ end
74
+
75
+ # def load_header(content)
76
+ # setup
77
+ # case @config['dyndoc']
78
+ # when 'dyndoc'
79
+ # Dyndoc.load(content, parse_header_only: true)
80
+ # else
81
+ # warn 'Unknown Dyndoc converter. Cannot load document header.'
82
+ # nil
83
+ # end
84
+ # end
85
+ end
86
+ end
87
+
88
+ # module Generators
89
+ # # Promotes select Dyndoc attributes to Jekyll front matter
90
+ # class DyndocPreprocessor < Generator
91
+ # def generate(site)
92
+ # dyndoc_converter = JEKYLL_MIN_VERSION_3 ?
93
+ # site.find_converter_instance(Jekyll::Converters::DyndocConverter) :
94
+ # site.getConverterImpl(Jekyll::Converters::DyndocConverter)
95
+ # dyndoc_converter.setup
96
+ # unless (page_attr_prefix = site.config['dyndoc_page_attribute_prefix']).empty?
97
+ # page_attr_prefix = %(#{page_attr_prefix}-)
98
+ # end
99
+ # page_attr_prefix_l = page_attr_prefix.length
100
+ #
101
+ # site.pages.each do |page|
102
+ # if dyndoc_converter.matches(page.ext)
103
+ # next unless (doc = dyndoc_converter.load_header(page.content))
104
+ #
105
+ # page.data['title'] = doc.doctitle if doc.header?
106
+ # page.data['author'] = doc.author if doc.author
107
+ #
108
+ # unless (dyndoc_front_matter = doc.attributes
109
+ # .select {|name| name.start_with?(page_attr_prefix) }
110
+ # .map {|name, val| %(#{name[page_attr_prefix_l..-1]}: #{val}) }).empty?
111
+ # page.data.update(SafeYAML.load(dyndoc_front_matter * "\n"))
112
+ # end
113
+ #
114
+ # page.data['layout'] = 'default' unless page.data.key? 'layout'
115
+ # end
116
+ # end
117
+ #
118
+ # (JEKYLL_MIN_VERSION_3 ? site.posts.docs : site.posts).each do |post|
119
+ # if dyndoc_converter.matches(JEKYLL_MIN_VERSION_3 ? post.data['ext'] : post.ext)
120
+ # next unless (doc = dyndoc_converter.load_header(post.content))
121
+ #
122
+ # post.data['title'] = doc.doctitle if doc.header?
123
+ # post.data['author'] = doc.author if doc.author
124
+ # post.data['date'] = DateTime.parse(doc.revdate).to_time if doc.attr? 'revdate'
125
+ #
126
+ # unless (dyndoc_front_matter = doc.attributes
127
+ # .select {|name| name.start_with?(page_attr_prefix) }
128
+ # .map {|name, val| %(#{name[page_attr_prefix_l..-1]}: #{val}) }).empty?
129
+ # post.data.update(SafeYAML.load(dyndoc_front_matter * "\n"))
130
+ # end
131
+ #
132
+ # post.data['layout'] = 'post' unless post.data.key? 'layout'
133
+ # end
134
+ # end
135
+ # end
136
+ # end
137
+ # end
138
+
139
+ module Filters
140
+ # Convert an Dyndoc string into HTML output.
141
+ #
142
+ # input - The Dyndoc String to convert.
143
+ #
144
+ # Returns the HTML formatted String.
145
+ def dyndocify(input)
146
+ site = @context.registers[:site]
147
+ converter = JEKYLL_MIN_VERSION_3 ?
148
+ site.find_converter_instance(Jekyll::Converters::DyndocConverter) :
149
+ site.getConverterImpl(Jekyll::Converters::DyndocConverter)
150
+ converter.convert(input)
151
+ end
152
+ end
153
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-dyndoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - CQLS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dyndoc-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.0
27
+ description: |2
28
+ Dyndoc jekyll plugin.
29
+ email: rdrouilh@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/jekyll-dyndoc.rb
35
+ homepage: http://cqls.upmf-grenoble.fr
36
+ licenses:
37
+ - MIT
38
+ - GPL-2
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements:
55
+ - none
56
+ rubyforge_project:
57
+ rubygems_version: 2.0.14
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: jekyll dyndoc
61
+ test_files: []