paperwork 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88ee93586dfaeee4e866d016e2590a7d0fe48e2401dc5c29f5a9307adfac54c5
4
- data.tar.gz: 6e237a15962eec55281ecdd1d93b14a26502d5f53793c7f164e2fdc7780727b3
3
+ metadata.gz: 6f3fcb5700f4771e6a62a4079c2a87ac9e4a714a0daeb74fb6054a8ca6d05e4a
4
+ data.tar.gz: 9031d29cd317e2cb03cd92eb32531818cc75f8198917cce31a730f1b3f9667a4
5
5
  SHA512:
6
- metadata.gz: f30ee505178ea14ff03258a0f807b1b7aacbd2c738f5d025a6e339a78bab132b897e823c0f90278ce0d69e6751df5446207591c35e8b6b7ca7c122a7579df15c
7
- data.tar.gz: ed1b2dd3d7713bccb6def5fb4b84c48af51620525960a1ea38db6c5800070c4a29113e34527d2703f80acab7cca6509a30ecb2e0f493ac3951f785dbe0c1f337
6
+ metadata.gz: 10071a1995561b9e5556e04e817e84ad335389a8b99912487c02ea8999043c2ed356c227d1c7d620cc1a4f7ad1149671d9c859816bc7d22babd28c298df02215
7
+ data.tar.gz: d77e0e2b16d1cad1e23c0ba6b46dc63a1a62cdd97bf44f76d0d988e143490eaa07b33a612924b149e51c01eacb05e1409fd0e0d444560655c0c85580498d89ee
data/.gitlab-ci.yml CHANGED
@@ -84,6 +84,5 @@ pages:
84
84
  paths:
85
85
  - public
86
86
  script:
87
- - mkdir public
88
- - mv .work/doc/build/* public/
87
+ - mv .work/doc/build public
89
88
  - mv .work/coverage public/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperwork (0.4.0)
4
+ paperwork (0.5.1)
5
5
  listen (~> 3.4.1)
6
6
  rake (~> 12.3)
7
7
  redcarpet (~> 3.5.0)
@@ -10,38 +10,38 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- ast (2.4.1)
13
+ ast (2.4.2)
14
14
  byebug (11.1.3)
15
- diff-lcs (1.4.4)
16
- docile (1.3.2)
17
- ffi (1.14.2)
15
+ diff-lcs (1.5.0)
16
+ docile (1.4.0)
17
+ ffi (1.15.5)
18
18
  listen (3.4.1)
19
19
  rb-fsevent (~> 0.10, >= 0.10.3)
20
20
  rb-inotify (~> 0.9, >= 0.9.10)
21
- parallel (1.19.2)
22
- parser (2.7.1.4)
21
+ parallel (1.22.1)
22
+ parser (3.1.2.0)
23
23
  ast (~> 2.4.1)
24
- rainbow (3.0.0)
24
+ rainbow (3.1.1)
25
25
  rake (12.3.3)
26
- rb-fsevent (0.10.4)
26
+ rb-fsevent (0.11.1)
27
27
  rb-inotify (0.10.1)
28
28
  ffi (~> 1.0)
29
29
  redcarpet (3.5.1)
30
- regexp_parser (1.7.1)
31
- rexml (3.2.4)
32
- rspec (3.9.0)
33
- rspec-core (~> 3.9.0)
34
- rspec-expectations (~> 3.9.0)
35
- rspec-mocks (~> 3.9.0)
36
- rspec-core (3.9.2)
37
- rspec-support (~> 3.9.3)
38
- rspec-expectations (3.9.2)
30
+ regexp_parser (2.5.0)
31
+ rexml (3.2.5)
32
+ rspec (3.11.0)
33
+ rspec-core (~> 3.11.0)
34
+ rspec-expectations (~> 3.11.0)
35
+ rspec-mocks (~> 3.11.0)
36
+ rspec-core (3.11.0)
37
+ rspec-support (~> 3.11.0)
38
+ rspec-expectations (3.11.0)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-mocks (3.9.1)
40
+ rspec-support (~> 3.11.0)
41
+ rspec-mocks (3.11.1)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-support (3.9.3)
43
+ rspec-support (~> 3.11.0)
44
+ rspec-support (3.11.0)
45
45
  rspec_junit_formatter (0.4.1)
46
46
  rspec-core (>= 2, < 4, != 2.12.0)
47
47
  rubocop (0.87.1)
@@ -53,15 +53,15 @@ GEM
53
53
  rubocop-ast (>= 0.1.0, < 1.0)
54
54
  ruby-progressbar (~> 1.7)
55
55
  unicode-display_width (>= 1.4.0, < 2.0)
56
- rubocop-ast (0.1.0)
57
- parser (>= 2.7.0.1)
58
- ruby-progressbar (1.10.1)
56
+ rubocop-ast (0.8.0)
57
+ parser (>= 2.7.1.5)
58
+ ruby-progressbar (1.11.0)
59
59
  simplecov (0.18.5)
60
60
  docile (~> 1.1)
61
61
  simplecov-html (~> 0.11)
62
- simplecov-html (0.12.2)
62
+ simplecov-html (0.12.3)
63
63
  thor (1.1.0)
64
- unicode-display_width (1.7.0)
64
+ unicode-display_width (1.8.0)
65
65
 
66
66
  PLATFORMS
67
67
  ruby
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
  title: paperwork
3
3
  ---
4
4
 
5
- # paperwork [![w-10](https://gitlab.com/couchbelag/paperwork/badges/master/pipeline.svg)](https://gitlab.com/couchbelag/paperwork/-/commits/master)[![w-10](https://gitlab.com/couchbelag/paperwork/badges/master/coverage.svg)](https://couchbelag.gitlab.io/paperwork/coverage)
5
+ # paperwork
6
+
7
+ [![w-10](https://gitlab.com/couchbelag/paperwork/badges/master/pipeline.svg)](https://gitlab.com/couchbelag/paperwork/-/commits/master)[![w-10](https://gitlab.com/couchbelag/paperwork/badges/master/coverage.svg)](https://couchbelag.gitlab.io/paperwork/coverage)
6
8
 
7
9
 
8
10
  ### The *paperwork gem* is an aproach to create appealing documentation from markdown documents.
@@ -48,7 +48,7 @@ module DocRenderer
48
48
  # end
49
49
 
50
50
  def paragraph(text)
51
- definition_list(text.strip)
51
+ "<p>#{definition_list(text.strip)}</p>"
52
52
  end
53
53
 
54
54
  def table(header, body)
@@ -60,4 +60,10 @@ module InfoHelpers
60
60
  def footer_text
61
61
  data.paperwork.footer if paperwork?
62
62
  end
63
+
64
+ def toc?
65
+ !data.paperwork.config.nil? &&
66
+ !data.paperwork.config.toc.nil? &&
67
+ data.paperwork.config.toc
68
+ end
63
69
  end
@@ -4,5 +4,14 @@ import $ from "jquery";
4
4
  import 'popper.js';
5
5
  import 'bootstrap';
6
6
  import mermaid from "mermaid";
7
+ import {getTableOfContents} from './toc';
7
8
 
8
9
  mermaid.initialize({startOnLoad:true});
10
+
11
+ $(()=>{
12
+ var sidebar = $(".toc.sidebar > ul")
13
+ var topbar = $(".toc.topbar > ul")
14
+ var toc = getTableOfContents();
15
+ toc.insertTo(sidebar);
16
+ toc.insertTo(topbar);
17
+ });
@@ -0,0 +1,64 @@
1
+ import $ from "jquery";
2
+
3
+ var idCounter = 0;
4
+
5
+ class Section {
6
+ constructor(element=null) {
7
+ this.children = [];
8
+ this.element = element;
9
+
10
+ if (this.element) {
11
+ this.anchor = "paperwork-h-" + ++idCounter;
12
+ } else {
13
+ this.element = $("body");
14
+ }
15
+
16
+ this.element.find(":header").each((index, elem)=>{
17
+ this.add(new Section($(elem)));
18
+ });
19
+ }
20
+
21
+ add(childSection) {
22
+ this.children.push(childSection);
23
+ }
24
+
25
+ id() {
26
+ return this.anchor;
27
+ }
28
+
29
+ level() {
30
+ return this.element.prop("tagName").toLowerCase();
31
+ }
32
+
33
+ mark() {
34
+ if (this.level() != "body") {
35
+ // create anchor
36
+ this.element.before("<div id='" + this.id() + "'></div>");
37
+ }
38
+ this.children.forEach((child)=>{
39
+ child.mark();
40
+ });
41
+ }
42
+
43
+ insertTo(target) {
44
+ if (this.level() != "body") {
45
+ // link to anchor
46
+ target.append("<li class='toc-" + this.level() + "'><a href='#" + this.id() + "'>" + this.text() + "</a></li>");
47
+ }
48
+ this.children.forEach((child)=>{
49
+ child.insertTo(target);
50
+ });
51
+ }
52
+
53
+ text() {
54
+ return this.element.text();
55
+ }
56
+ }
57
+
58
+ function getTableOfContents() {
59
+ var toc = new Section();
60
+ toc.mark();
61
+ return toc;
62
+ }
63
+
64
+ export { getTableOfContents };
@@ -0,0 +1,6 @@
1
+ <%= partial "layouts/header" %>
2
+ <div class="row">
3
+ <div class="col">
4
+ <%= body %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,25 @@
1
+ <div class="d-flex">
2
+ <div class="d-xl-block d-lg-block d-md-block d-none">
3
+ <%= partial "layouts/toc", locals: {classes: [:sidebar]} %>
4
+ </div>
5
+
6
+ <div>
7
+ <%= partial "layouts/header" %>
8
+
9
+ <div class="row d-xl-none d-lg-none d-md-none ">
10
+ <div class="col">
11
+ <%= partial "layouts/toc", locals: {classes: [:topbar]} %>
12
+ </div>
13
+ </div>
14
+
15
+ <div class="row">
16
+ <div class="col">
17
+ <%= body %>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+ <div class="v-spacer-2 d-xl-block d-lg-block d-md-block d-sm-none d-xs-none"></div>
23
+ <div class="v-spacer-2 d-xl-block d-lg-block d-md-none d-sm-none d-xs-none"></div>
24
+ <div class="v-spacer-3 d-xl-block d-lg-none d-md-none d-sm-none d-xs-none"></div>
25
+ </div>
@@ -29,14 +29,21 @@
29
29
  <body>
30
30
  <%= partial "layouts/navbar" %>
31
31
 
32
+ <% if toc? %>
33
+ <div class="container-fluid">
34
+ <div class="row">
35
+ <div class="col">
36
+ <%= partial "layouts/content_with_toc", locals: {body: body} %>
37
+ </div>
38
+ </div>
39
+ <% else %>
32
40
  <div class="container">
33
- <%= partial "layouts/header" %>
34
-
35
41
  <div class="row">
36
42
  <div class="col">
37
- <%= body %>
43
+ <%= partial "layouts/content", locals: {body: body} %>
38
44
  </div>
39
45
  </div>
46
+ <% end %>
40
47
 
41
48
  <div class="row mt-5 pb-4">
42
49
  <div class="col text-right small border-top">
@@ -1,14 +1,14 @@
1
1
  <div class="row">
2
2
  <div class="col-sm-7 mb-5">
3
- <span class="display-2"><%= yield_content :title %></span>
3
+ <span class="page-title"><%= yield_content :title %></span>
4
4
  <br>
5
- <span class="display-4"><%= yield_content :subtitle %></span>
5
+ <span class="page-sub-title"><%= yield_content :subtitle %></span>
6
6
  </div>
7
7
 
8
8
  <div class="col-sm-5">
9
9
 
10
10
  <div class="row">
11
- <div class="col text-right sub-title mb-2">
11
+ <div class="col text-right page-category mb-2">
12
12
  <%= yield_content :category %>
13
13
  </div>
14
14
  </div>
@@ -0,0 +1,9 @@
1
+ <%
2
+ classes ||= []
3
+ classes << "toc"
4
+ %>
5
+
6
+ <div class="<%= classes.join(" ") %>">
7
+ <div class="title">Table of Contents</div>
8
+ <ul class="list-unstyled"></ul>
9
+ </div>
@@ -1,8 +1,16 @@
1
1
  @import "../../node_modules/bootstrap/dist/css/bootstrap";
2
2
  @import "./bootstrap-icons.css";
3
3
 
4
- .sub-title {
5
- font-size: 2.2rem;
4
+ .page-title {
5
+ font-size: 3rem;
6
+ }
7
+
8
+ .page-sub-title {
9
+ font-size: 2rem;
10
+ }
11
+
12
+ .page-category {
13
+ font-size: 1.5rem;
6
14
  }
7
15
 
8
16
  $header-siblings-margin: 1rem;
@@ -29,4 +37,39 @@ pre.highlight {
29
37
  padding: 0.3rem;
30
38
  margin-top: 1rem;
31
39
  margin-bottom: 1rem;
32
- }
40
+ }
41
+
42
+ .toc {
43
+ padding-top: 1rem;
44
+ white-space: nowrap;
45
+
46
+ &.sidebar {
47
+ position: sticky;
48
+ top: 4rem;
49
+ margin-right: 5rem;
50
+ width: 12rem;
51
+ overflow: hidden;
52
+ text-overflow: ellipsis;
53
+ }
54
+
55
+ .title {
56
+ font-weight: bold;
57
+ }
58
+
59
+ @for $i from 1 through 6 {
60
+ .toc-h#{$i} {
61
+ font-size: 0.8rem;
62
+ padding-left: #{($i - 1) * 0.5}rem;
63
+ }
64
+ }
65
+ }
66
+
67
+
68
+ .d-flex {
69
+ @for $i from 1 through 5 {
70
+ .v-spacer-#{$i} {
71
+ margin-left: #{$i * 2}rem;
72
+ }
73
+ }
74
+ }
75
+
@@ -2,6 +2,7 @@ const path = require('path');
2
2
 
3
3
  module.exports = {
4
4
  entry: './source/javascripts/site.js',
5
+ devtool: 'source-map',
5
6
 
6
7
  resolve: {
7
8
  modules: [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperwork
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
5
5
  end
data/paperwork.yml CHANGED
@@ -8,6 +8,7 @@ navbar:
8
8
 
9
9
  config:
10
10
  name: doc
11
+ toc: true
11
12
  sources:
12
13
  - README.md
13
14
  - nested_example/navdemo.md
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-19 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -178,10 +178,14 @@ files:
178
178
  - lib/paperwork/tasks/middleman_template/source/fonts/bootstrap-icons.woff2
179
179
  - lib/paperwork/tasks/middleman_template/source/images/.keep
180
180
  - lib/paperwork/tasks/middleman_template/source/javascripts/site.js
181
+ - lib/paperwork/tasks/middleman_template/source/javascripts/toc.js
182
+ - lib/paperwork/tasks/middleman_template/source/layouts/_content.erb
183
+ - lib/paperwork/tasks/middleman_template/source/layouts/_content_with_toc.erb
181
184
  - lib/paperwork/tasks/middleman_template/source/layouts/_document.erb
182
185
  - lib/paperwork/tasks/middleman_template/source/layouts/_header.erb
183
186
  - lib/paperwork/tasks/middleman_template/source/layouts/_info.erb
184
187
  - lib/paperwork/tasks/middleman_template/source/layouts/_navbar.erb
188
+ - lib/paperwork/tasks/middleman_template/source/layouts/_toc.erb
185
189
  - lib/paperwork/tasks/middleman_template/source/layouts/layout.erb
186
190
  - lib/paperwork/tasks/middleman_template/source/stylesheets/bootstrap-icons.css
187
191
  - lib/paperwork/tasks/middleman_template/source/stylesheets/rogue.css.erb