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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aae0ad2a0988f1ab3b183584b9c3be86c5bc013
4
- data.tar.gz: 44f347b0583e8d4ca3d1747c7937771f88e5ae8c
3
+ metadata.gz: ad7a199bae921cefac3fe964d453a85957266985
4
+ data.tar.gz: 17b3a141759854b013dfb907dd7fb4c901e7ad1f
5
5
  SHA512:
6
- metadata.gz: 5e9b679d27ee036868e06633687a98091d39ef8d2156ccb4751ae5286211cdd8889709edc0e7a864e839a68c27854e2670e185a82c1bfde5272d674b50f1021c
7
- data.tar.gz: 5d17aadfbc0335682eeec7917700ba87d4f67dd18f73a530beda3312b5f036b0834650cb708d722111302d271e61916fe0b37118eca21c710ca11e99f3b6d8a1
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:
@@ -36,6 +36,10 @@ module SyncReadme
36
36
  @raw_config['notice']
37
37
  end
38
38
 
39
+ def toc
40
+ @raw_config['toc']
41
+ end
42
+
39
43
  def password
40
44
  ENV['CONFLUENCE_PASSWORD'] || @raw_config['password']
41
45
  end
@@ -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 = Kramdown::Document.new(markdown, options).to_html
24
- value = "#{@notice}#{value}" if @notice
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
@@ -1,3 +1,3 @@
1
1
  module SyncReadme
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
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.1.0
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-05 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday