sync_readme 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/sync_readme/config.rb +4 -0
- data/lib/sync_readme/reader.rb +41 -3
- data/lib/sync_readme/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad7a199bae921cefac3fe964d453a85957266985
|
4
|
+
data.tar.gz: 17b3a141759854b013dfb907dd7fb4c901e7ad1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4af9909b137ae065b12a90db87b1ffcdd6c06a92af6c8172703d205726b3ebdf912439ad2bf799644811d452fbe7a63b6924ba4ba4649ca054c1f52098bc7d99
|
7
|
+
data.tar.gz: f43a1629c77d82f7423d5625947b1a6d33fa3c5c1dbf028d8fccc28d43afced41ac80c7eae76fe57a245fb13dac676f2bf214fdc927d68e047a8ca75948f2b34
|
data/README.md
CHANGED
@@ -32,6 +32,7 @@ readme:
|
|
32
32
|
notice: this file is sync'd! # optional, adds the notice (as html) to the top of the confluance docs
|
33
33
|
strip_title: false # optional, defaults false, strips the first h1 (#) tag from the file
|
34
34
|
syntax_highlighting: true # optional, defaults true, uses coderay syntax highlighting on code blocks
|
35
|
+
toc: true # optional, defaults false, can also be a hash of toc macro params
|
35
36
|
```
|
36
37
|
|
37
38
|
You can also set the following in your environment (ex: continuous integration) to store credentials:
|
data/lib/sync_readme/config.rb
CHANGED
data/lib/sync_readme/reader.rb
CHANGED
@@ -5,10 +5,46 @@ module SyncReadme
|
|
5
5
|
def initialize(config)
|
6
6
|
@file_contents = File.read(config.filename)
|
7
7
|
@notice = config.notice
|
8
|
+
@toc = config.toc
|
8
9
|
@strip_title = config.strip_title?
|
9
10
|
@highlighter = config.syntax_highlighting? ? 'coderay' : nil
|
10
11
|
end
|
11
12
|
|
13
|
+
# See here for ToC parameters
|
14
|
+
# https://confluence.atlassian.com/display/CONF55/Table+of+Contents+Macro
|
15
|
+
def toc
|
16
|
+
return '' unless @toc
|
17
|
+
@toc = {} unless @toc.is_a?(Hash)
|
18
|
+
params = {
|
19
|
+
'printable' => true,
|
20
|
+
'style' => 'circle',
|
21
|
+
'maxLevel' => 2,
|
22
|
+
'indent' => '5px',
|
23
|
+
'minLevel' => 2,
|
24
|
+
'exclude' => '[1/2]',
|
25
|
+
'outline' => true,
|
26
|
+
'type' => 'list',
|
27
|
+
'include' => '.*',
|
28
|
+
'class' => 'sync_readme_toc'
|
29
|
+
}.merge(@toc)
|
30
|
+
|
31
|
+
return <<-TOC
|
32
|
+
<ac:structured-macro ac:name="toc">
|
33
|
+
<ac:parameter ac:name="printable">#{params['printable']}</ac:parameter>
|
34
|
+
<ac:parameter ac:name="style">#{params['style']}</ac:parameter>
|
35
|
+
<ac:parameter ac:name="maxLevel">#{params['maxLevel']}</ac:parameter>
|
36
|
+
<ac:parameter ac:name="indent">#{params['indent']}</ac:parameter>
|
37
|
+
<ac:parameter ac:name="minLevel">#{params['minLevel']}</ac:parameter>
|
38
|
+
<ac:parameter ac:name="class">#{params['class']}</ac:parameter>
|
39
|
+
<ac:parameter ac:name="exclude">#{params['exclude']}</ac:parameter>
|
40
|
+
<ac:parameter ac:name="type">#{params['type']}</ac:parameter>
|
41
|
+
<ac:parameter ac:name="outline">#{params['outline']}</ac:parameter>
|
42
|
+
<ac:parameter ac:name="include">#{params['include']}</ac:parameter>
|
43
|
+
</ac:structured-macro>
|
44
|
+
TOC
|
45
|
+
end
|
46
|
+
|
47
|
+
|
12
48
|
def html
|
13
49
|
markdown = @file_contents
|
14
50
|
markdown.sub!(/# .*\n/, '') if @strip_title
|
@@ -20,9 +56,11 @@ module SyncReadme
|
|
20
56
|
line_numbers: 'table'
|
21
57
|
}
|
22
58
|
}
|
23
|
-
value =
|
24
|
-
value
|
25
|
-
value
|
59
|
+
value = []
|
60
|
+
value << "<p>#{@notice}</p>" if @notice
|
61
|
+
value << toc if @toc
|
62
|
+
value << Kramdown::Document.new(markdown, options).to_html
|
63
|
+
value.join("\n")
|
26
64
|
end
|
27
65
|
end
|
28
66
|
end
|
data/lib/sync_readme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sync_readme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Ives
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|