ex-doc-include 0.2

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 (4) hide show
  1. checksums.yaml +7 -0
  2. data/assets/style.css +143 -0
  3. data/lib/ex-doc-include.rb +99 -0
  4. metadata +40 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 82735343deff232e1a0c4eeebb632ac7a0d66545cd2f5be0825e1e41f2a5e253
4
+ data.tar.gz: ec97ab375ae697d6920f1f766f344d65cb3c5d1d572981c1745d9ae5750e6a61
5
+ SHA512:
6
+ metadata.gz: 37348ca9e62132d709a573b3388114a521553f7937e71dc668c13a072ac2d99046e22a0811a507d17f0adb21afb5e958fba7cf7f2cae5c4262f2b703bd2410bf
7
+ data.tar.gz: 1ee732f617a0d25750c11069e45fe26d770f5690065f0d82ce2edc8824e8c13ba7c0326bdaab01d0fefa0f6b6f35369b5148f13b40a11ed6cf6d2c2419a3dbc4
data/assets/style.css ADDED
@@ -0,0 +1,143 @@
1
+ * {
2
+ border-radius: 20px;
3
+ }
4
+
5
+ html {
6
+ font-size: 13pt;
7
+ box-sizing: border-box;
8
+ background-color: white;
9
+ }
10
+
11
+ body.article {
12
+ margin-top: 4rem;
13
+ margin-left: 2.5%;
14
+ display: grid;
15
+ grid-template-columns: 17.5% 1fr;
16
+ gap: 40px;
17
+ color: rgba(15.5625, 21.6875, 25.9375, 0.8);
18
+ font-family: "Now";
19
+ line-height: 1.45rem;
20
+ # align-items: baseline;
21
+ }
22
+ body.article:has(.toc a:hover) #content {
23
+ opacity: 0.1;
24
+ }
25
+ body.article:has(.toc a:hover) .toc {
26
+ overflow: visible;
27
+ }
28
+ body.article #content {
29
+ grid-column: 2;
30
+ width: 80ch;
31
+ margin-left: 2ch;
32
+ transition: opacity 1.2s;
33
+ }
34
+ body.article p {
35
+ margin: 0.5em 0 0;
36
+ }
37
+ body.article h2 {
38
+ margin-top: 0px;
39
+ padding: 1%;
40
+ background-color: rgb(0, 49, 83);
41
+ border-radius: 10px;
42
+ color: beige;
43
+ }
44
+ body.article h3 {
45
+ margin-top: 5rem;
46
+ padding: 1%;
47
+ background-color: rgba(0, 49, 83, 0.25);
48
+ color: rgba(13.9025, 30.3175, 41.7075, 0.8);
49
+ border-radius: 10px;
50
+ }
51
+ body.article .toc {
52
+ width: 100%;
53
+ overflow: hidden;
54
+ margin-left: 1%;
55
+ position: sticky;
56
+ top: 20px;
57
+ padding: 20px;
58
+ font-size: 0.8rem;
59
+ background-color: rgba(0, 49, 83, 0.25);
60
+ }
61
+ body.article .toc ul {
62
+ list-style: none;
63
+ padding-left: 20px;
64
+ display: block;
65
+ }
66
+ body.article .toc ul li a {
67
+ color: rgba(20.75, 45.25, 62.25, 0.5);
68
+ text-decoration: none;
69
+ transition: color 0.9s;
70
+ text-overflow: ellipsis;
71
+ overflow: hidden;
72
+ white-space: nowrap;
73
+ }
74
+ body.article .toc ul li a:hover {
75
+ color: rgba(0, 49, 83, 0.8);
76
+ border-bottom: dashed 1px;
77
+ }
78
+
79
+ div.sidebarblock {
80
+ margin-top: 1.5rem;
81
+ margin-bottom: 1rem;
82
+ padding: 0.5em 0.5em 1em 1em;
83
+ background-color: rgba(23.2815, 37.4425, 47.2685, 0.08);
84
+ }
85
+ div.sidebarblock .title {
86
+ text-align: center;
87
+ font-size: 1.25rem;
88
+ }
89
+
90
+ #footer {
91
+ grid-column: 2;
92
+ width: 80ch;
93
+ margin-left: 2ch;
94
+ }
95
+ #footer #footer-text {
96
+ font-size: 0.75rem;
97
+ }
98
+
99
+ .api-ref {
100
+ margin-bottom: 1rem;
101
+ margin-top: 3rem;
102
+ background-color: rgb(0, 49, 83);
103
+ padding: 1%;
104
+ border-radius: 10px;
105
+ color: beige;
106
+ font-weight: 500;
107
+ font-family: "Fira Code";
108
+ font-size: 1rem;
109
+ }
110
+
111
+ .API-REF {
112
+ margin-bottom: 1rem;
113
+ margin-top: 3rem;
114
+ background-color: rgb(0, 49, 83);
115
+ padding: 1%;
116
+ border-radius: 10px;
117
+ color: beige;
118
+ font-weight: 500;
119
+ font-family: "Fira Code";
120
+ font-size: 1rem;
121
+ }
122
+
123
+ .localsect {
124
+ font-size: 1.25rem;
125
+ font-weight: 500;
126
+ margin-top: 5rem;
127
+ }
128
+
129
+ .method {
130
+ margin-bottom: 1rem;
131
+ margin-top: 3rem;
132
+ background-color: rgb(0, 49, 83);
133
+ padding: 1%;
134
+ border-radius: 10px;
135
+ color: beige;
136
+ font-weight: 500;
137
+ font-family: "Fira Code";
138
+ font-size: 1rem;
139
+ background-color: rgba(0, 49, 83, 0.25);
140
+ color: rgba(13.9025, 30.3175, 41.7075, 0.8);
141
+ }
142
+
143
+ /*# sourceMappingURL=style.css.map */
@@ -0,0 +1,99 @@
1
+ require 'asciidoctor'
2
+
3
+ class DocBlocksExtractor
4
+
5
+ def initialize()
6
+ @count_leading_spaces = 0
7
+ @active_block = false
8
+ end
9
+
10
+ def _store_block_info(l)
11
+ @count_leading_spaces = l.length - l.lstrip.length
12
+ end
13
+
14
+ def _process_as_block_line(l)
15
+
16
+ min_col = [@count_leading_spaces, l.length].min
17
+ return l.slice( min_col..)
18
+ end
19
+
20
+ def _tokenize(l)
21
+ return l.split.reject { |c| c.empty? }.each { |t| t.strip }
22
+ end
23
+
24
+ def _block_open?(toks)
25
+ return (not @active_block and toks.slice(..1) == ['/*!', '#ex-doc'])
26
+ end
27
+
28
+ def _block_role(toks)
29
+ if toks.length >= 3
30
+ return toks[2]
31
+ end
32
+ return ''
33
+
34
+ end
35
+
36
+ def _block_close?(toks)
37
+ return (@active_block and toks.slice(-1) == '*/')
38
+ end
39
+
40
+ def process_line(l)
41
+ toks = _tokenize(l)
42
+ if _block_open?(toks)
43
+ toggle_active_block
44
+ _store_block_info(l)
45
+ return _block_role(toks)
46
+
47
+ elsif _block_close?(toks)
48
+ toggle_active_block
49
+ l = l.rstrip.slice(...-2).rstrip
50
+ return _process_as_block_line(l)
51
+
52
+ elsif @active_block
53
+ return _process_as_block_line(l)
54
+ end
55
+
56
+ end
57
+
58
+ def to_proc = method(:process_line).to_proc
59
+
60
+ def toggle_active_block
61
+ @active_block = !@active_block
62
+ return @active_block
63
+ end
64
+ end
65
+
66
+
67
+ class ExDocIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
68
+ def handles? target
69
+ target.end_with? '.h', '.hpp', '.cpp'
70
+ end
71
+
72
+ def process doc, reader, target, attributes
73
+ if not attributes.key? 'expand'
74
+ target_name = File.basename(target,'.*')
75
+ expanded_target = "#{target_name}.html"
76
+ if attributes.key? 'out-dir'
77
+ expanded_target = attributes["out-dir"] + "/" + expanded_target
78
+ end
79
+
80
+ Asciidoctor.convert("include::#{target}[expand=true]", to_file: expanded_target, attributes: doc.attributes)
81
+
82
+ text = if attributes.key? 'link' then attributes["link"] else target_name end
83
+ content = ["link:#{expanded_target}[#{text}]"]
84
+ else
85
+ content =
86
+ IO.readlines(target)
87
+ .map( &DocBlocksExtractor.new() )
88
+ .compact
89
+ #content = ["linked"]
90
+ end
91
+ reader.push_include content, target, target, 1, attributes
92
+ return reader
93
+ end
94
+ end
95
+
96
+
97
+ Asciidoctor::Extensions.register do
98
+ include_processor ExDocIncludeProcessor
99
+ end
metadata ADDED
@@ -0,0 +1,40 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ex-doc-include
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - Giuseppe Puoti
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ executables: []
13
+ extensions: []
14
+ extra_rdoc_files: []
15
+ files:
16
+ - assets/style.css
17
+ - lib/ex-doc-include.rb
18
+ homepage: https://github.com/gpuoti/ex-doc-include
19
+ licenses:
20
+ - MIT
21
+ metadata: {}
22
+ rdoc_options: []
23
+ require_paths:
24
+ - lib
25
+ required_ruby_version: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ required_rubygems_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ requirements: []
36
+ rubygems_version: 3.6.9
37
+ specification_version: 4
38
+ summary: 'AsciiDoctor plug-in that lets you borrow the content of specific C++ documentation
39
+ block comments (/*! #ex-doc ... */) directly into your AsciiDoc files.'
40
+ test_files: []