asciidoctor-godoc 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +306 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.adoc +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +54 -0
- data/LICENSE.txt +21 -0
- data/README.adoc +236 -0
- data/Rakefile +30 -0
- data/lib/asciidoctor/godoc/inline_macro.rb +58 -0
- data/lib/asciidoctor/godoc/version.rb +7 -0
- data/lib/asciidoctor/godoc.rb +9 -0
- data/lib/asciidoctor-godoc.rb +3 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 290030c6bab807edcb49c4ccdc07f4baf8ab959185c7d7091ed78703a3fc4c6c
|
4
|
+
data.tar.gz: 3df07c648e51cacc626d765af60fd64f1bb819dc3de9b1b1d679cf11250a522e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c754b83762c25d7416ef08dacaaa299721a1d4b14190c50bd923126d845bb190283bfe8e50a2b9c4499563bfeee8703e29bb597dee44b9d8fabb91b7c00e857
|
7
|
+
data.tar.gz: 9908d887be80089d6a1a7a05a7a5ab2dc000e3e74355c11ea8edfb3da10664c25ca06c9df2ef54def7986512132d18d1a10ad0b406b0fc9e2e168f2498f837bd
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,306 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-minitest
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.6
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/StringLiteralsInInterpolation:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
Layout/LineLength:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Naming/FileName:
|
20
|
+
Enabled: true
|
21
|
+
Exclude: [ lib/asciidoctor-godoc.rb ]
|
22
|
+
|
23
|
+
Gemspec/DeprecatedAttributeAssignment:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Gemspec/RequireMFA:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Layout/LineContinuationLeadingSpace:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
Layout/LineContinuationSpacing:
|
33
|
+
Enabled: true
|
34
|
+
|
35
|
+
Layout/LineEndStringConcatenationIndentation:
|
36
|
+
Enabled: true
|
37
|
+
|
38
|
+
Layout/SpaceBeforeBrackets:
|
39
|
+
Enabled: true
|
40
|
+
|
41
|
+
Lint/AmbiguousAssignment:
|
42
|
+
Enabled: true
|
43
|
+
|
44
|
+
Lint/AmbiguousOperatorPrecedence:
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
Lint/AmbiguousRange:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
Lint/ConstantOverwrittenInRescue:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Lint/DeprecatedConstants:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Lint/DuplicateBranch:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Lint/DuplicateMagicComment:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Lint/DuplicateRegexpCharacterClassElement:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Lint/EmptyBlock:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
Lint/EmptyClass:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Lint/EmptyInPattern:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
Lint/LambdaWithoutLiteralBlock:
|
78
|
+
Enabled: true
|
79
|
+
|
80
|
+
Lint/NoReturnInBeginEndBlocks:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Lint/NonAtomicFileOperation:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Lint/NumberedParameterAssignment:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
Lint/OrAssignmentToConstant:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
Lint/RedundantDirGlobSort:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Lint/RefinementImportMethods:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Lint/RequireRangeParentheses:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
Lint/RequireRelativeSelfPath:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
Lint/SymbolConversion:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
Lint/ToEnumArguments:
|
108
|
+
Enabled: true
|
109
|
+
|
110
|
+
Lint/TripleQuotes:
|
111
|
+
Enabled: true
|
112
|
+
|
113
|
+
Lint/UnexpectedBlockArity:
|
114
|
+
Enabled: true
|
115
|
+
|
116
|
+
Lint/UnmodifiedReduceAccumulator:
|
117
|
+
Enabled: true
|
118
|
+
|
119
|
+
Lint/UselessRuby2Keywords:
|
120
|
+
Enabled: true
|
121
|
+
|
122
|
+
Naming/BlockForwarding:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
Security/CompoundHash:
|
126
|
+
Enabled: true
|
127
|
+
|
128
|
+
Security/IoMethods:
|
129
|
+
Enabled: true
|
130
|
+
|
131
|
+
Style/ArgumentsForwarding:
|
132
|
+
Enabled: true
|
133
|
+
|
134
|
+
Style/ArrayIntersect:
|
135
|
+
Enabled: true
|
136
|
+
|
137
|
+
Style/CollectionCompact:
|
138
|
+
Enabled: true
|
139
|
+
|
140
|
+
Style/DocumentDynamicEvalDefinition:
|
141
|
+
Enabled: true
|
142
|
+
|
143
|
+
Style/EmptyHeredoc:
|
144
|
+
Enabled: true
|
145
|
+
|
146
|
+
Style/EndlessMethod:
|
147
|
+
Enabled: true
|
148
|
+
|
149
|
+
Style/EnvHome:
|
150
|
+
Enabled: true
|
151
|
+
|
152
|
+
Style/FetchEnvVar:
|
153
|
+
Enabled: true
|
154
|
+
|
155
|
+
Style/FileRead:
|
156
|
+
Enabled: true
|
157
|
+
|
158
|
+
Style/FileWrite:
|
159
|
+
Enabled: true
|
160
|
+
|
161
|
+
Style/HashConversion:
|
162
|
+
Enabled: true
|
163
|
+
|
164
|
+
Style/HashExcept:
|
165
|
+
Enabled: true
|
166
|
+
|
167
|
+
Style/IfWithBooleanLiteralBranches:
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
Style/InPatternThen:
|
171
|
+
Enabled: true
|
172
|
+
|
173
|
+
Style/MagicCommentFormat:
|
174
|
+
Enabled: true
|
175
|
+
|
176
|
+
Style/MapCompactWithConditionalBlock:
|
177
|
+
Enabled: true
|
178
|
+
|
179
|
+
Style/MapToHash:
|
180
|
+
Enabled: true
|
181
|
+
|
182
|
+
Style/MultilineInPatternThen:
|
183
|
+
Enabled: true
|
184
|
+
|
185
|
+
Style/NegatedIfElseCondition:
|
186
|
+
Enabled: true
|
187
|
+
|
188
|
+
Style/NestedFileDirname:
|
189
|
+
Enabled: true
|
190
|
+
|
191
|
+
Style/NilLambda:
|
192
|
+
Enabled: true
|
193
|
+
|
194
|
+
Style/NumberedParameters:
|
195
|
+
Enabled: true
|
196
|
+
|
197
|
+
Style/NumberedParametersLimit:
|
198
|
+
Enabled: true
|
199
|
+
|
200
|
+
Style/ObjectThen:
|
201
|
+
Enabled: true
|
202
|
+
|
203
|
+
Style/OpenStructUse:
|
204
|
+
Enabled: true
|
205
|
+
|
206
|
+
Style/OperatorMethodCall:
|
207
|
+
Enabled: true
|
208
|
+
|
209
|
+
Style/QuotedSymbols:
|
210
|
+
Enabled: true
|
211
|
+
|
212
|
+
Style/RedundantArgument:
|
213
|
+
Enabled: true
|
214
|
+
|
215
|
+
Style/RedundantConstantBase:
|
216
|
+
Enabled: true
|
217
|
+
|
218
|
+
Style/RedundantEach:
|
219
|
+
Enabled: true
|
220
|
+
|
221
|
+
Style/RedundantInitialize:
|
222
|
+
Enabled: true
|
223
|
+
|
224
|
+
Style/RedundantSelfAssignmentBranch:
|
225
|
+
Enabled: true
|
226
|
+
|
227
|
+
Style/RedundantStringEscape:
|
228
|
+
Enabled: true
|
229
|
+
|
230
|
+
Style/SelectByRegexp:
|
231
|
+
Enabled: true
|
232
|
+
|
233
|
+
Style/StringChars:
|
234
|
+
Enabled: true
|
235
|
+
|
236
|
+
Style/SwapValues:
|
237
|
+
Enabled: true
|
238
|
+
|
239
|
+
Minitest/AssertInDelta:
|
240
|
+
Enabled: true
|
241
|
+
|
242
|
+
Minitest/AssertKindOf:
|
243
|
+
Enabled: true
|
244
|
+
|
245
|
+
Minitest/AssertOutput:
|
246
|
+
Enabled: true
|
247
|
+
|
248
|
+
Minitest/AssertPathExists:
|
249
|
+
Enabled: true
|
250
|
+
|
251
|
+
Minitest/AssertPredicate:
|
252
|
+
Enabled: true
|
253
|
+
|
254
|
+
Minitest/AssertRaisesCompoundBody:
|
255
|
+
Enabled: true
|
256
|
+
|
257
|
+
Minitest/AssertRaisesWithRegexpArgument:
|
258
|
+
Enabled: true
|
259
|
+
|
260
|
+
Minitest/AssertSilent:
|
261
|
+
Enabled: true
|
262
|
+
|
263
|
+
Minitest/AssertWithExpectedArgument:
|
264
|
+
Enabled: true
|
265
|
+
|
266
|
+
Minitest/AssertionInLifecycleHook:
|
267
|
+
Enabled: true
|
268
|
+
|
269
|
+
Minitest/DuplicateTestRun:
|
270
|
+
Enabled: true
|
271
|
+
|
272
|
+
Minitest/EmptyLineBeforeAssertionMethods:
|
273
|
+
Enabled: true
|
274
|
+
|
275
|
+
Minitest/LiteralAsActualArgument:
|
276
|
+
Enabled: true
|
277
|
+
|
278
|
+
Minitest/MultipleAssertions:
|
279
|
+
Enabled: true
|
280
|
+
|
281
|
+
Minitest/RefuteInDelta:
|
282
|
+
Enabled: true
|
283
|
+
|
284
|
+
Minitest/RefuteKindOf:
|
285
|
+
Enabled: true
|
286
|
+
|
287
|
+
Minitest/RefutePathExists:
|
288
|
+
Enabled: true
|
289
|
+
|
290
|
+
Minitest/RefutePredicate:
|
291
|
+
Enabled: true
|
292
|
+
|
293
|
+
Minitest/SkipEnsure:
|
294
|
+
Enabled: true
|
295
|
+
|
296
|
+
Minitest/SkipWithoutReason:
|
297
|
+
Enabled: true
|
298
|
+
|
299
|
+
Minitest/TestMethodName:
|
300
|
+
Enabled: true
|
301
|
+
|
302
|
+
Minitest/UnreachableAssertion:
|
303
|
+
Enabled: true
|
304
|
+
|
305
|
+
Minitest/UnspecifiedException:
|
306
|
+
Enabled: true
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.2
|
data/CHANGELOG.adoc
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
group :lint do
|
8
|
+
gem "rubocop", "~> 1.40.0", require: false
|
9
|
+
gem "rubocop-minitest", "~> 0.25.0"
|
10
|
+
gem "rubocop-rake", "~> 0.6.0", require: false
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "minitest", "~> 5.16"
|
15
|
+
end
|
16
|
+
|
17
|
+
gem "rouge", "~> 4.0", group: :docs
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
asciidoctor-godoc (0.1.0)
|
5
|
+
asciidoctor (>= 2.0.0, < 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
asciidoctor (2.0.18)
|
11
|
+
ast (2.4.2)
|
12
|
+
json (2.6.3)
|
13
|
+
minitest (5.16.3)
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.1.3.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
rainbow (3.1.1)
|
18
|
+
rake (13.0.6)
|
19
|
+
regexp_parser (2.6.1)
|
20
|
+
rexml (3.2.5)
|
21
|
+
rouge (4.0.0)
|
22
|
+
rubocop (1.40.0)
|
23
|
+
json (~> 2.3)
|
24
|
+
parallel (~> 1.10)
|
25
|
+
parser (>= 3.1.2.1)
|
26
|
+
rainbow (>= 2.2.2, < 4.0)
|
27
|
+
regexp_parser (>= 1.8, < 3.0)
|
28
|
+
rexml (>= 3.2.5, < 4.0)
|
29
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
30
|
+
ruby-progressbar (~> 1.7)
|
31
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
32
|
+
rubocop-ast (1.24.0)
|
33
|
+
parser (>= 3.1.1.0)
|
34
|
+
rubocop-minitest (0.25.0)
|
35
|
+
rubocop (>= 0.90, < 2.0)
|
36
|
+
rubocop-rake (0.6.0)
|
37
|
+
rubocop (~> 1.0)
|
38
|
+
ruby-progressbar (1.11.0)
|
39
|
+
unicode-display_width (2.3.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
x86_64-linux
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
asciidoctor-godoc!
|
46
|
+
minitest (~> 5.16)
|
47
|
+
rake (~> 13.0.0)
|
48
|
+
rouge (~> 4.0)
|
49
|
+
rubocop (~> 1.40.0)
|
50
|
+
rubocop-minitest (~> 0.25.0)
|
51
|
+
rubocop-rake (~> 0.6.0)
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Abhinav Gupta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.adoc
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
= asciidoctor-godoc
|
2
|
+
:toc:
|
3
|
+
:url-godoc: https://pkg.go.dev
|
4
|
+
|
5
|
+
An asciidoctor extension that adds support for a `godoc` macro.
|
6
|
+
The macro allows you to reference types and functions in a Go package by name,
|
7
|
+
and links to their documentation on {url-godoc}[pkg.go.dev].
|
8
|
+
|
9
|
+
For example, given the following:
|
10
|
+
|
11
|
+
.Input
|
12
|
+
[,asciidoctor]
|
13
|
+
----
|
14
|
+
The godoc:http[] package provides
|
15
|
+
godoc:net/http#ServeMux[] for request routing.
|
16
|
+
Register zero or more godoc:net/http#Handler[handlers] against it,
|
17
|
+
and specify it as a godoc:net/http#Server.Handler[]
|
18
|
+
in your server's configuration.
|
19
|
+
----
|
20
|
+
|
21
|
+
.Output
|
22
|
+
[%collapsible]
|
23
|
+
====
|
24
|
+
The {url-godoc}/http[http] package provides
|
25
|
+
{url-godoc}/net/http#ServeMux[`http.ServeMux`] for request routing.
|
26
|
+
Register zero or more {url-godoc}/net/http#Handler[handlers] against it,
|
27
|
+
and specify it as a {url-godoc}/net/http#Server.Handler[`Server.Handler`]
|
28
|
+
in your server's configuration.
|
29
|
+
====
|
30
|
+
|
31
|
+
== Installation
|
32
|
+
|
33
|
+
=== With Bundler
|
34
|
+
|
35
|
+
To install the extension with bundler,
|
36
|
+
add the following to your Gemfile.
|
37
|
+
|
38
|
+
.Gemfile
|
39
|
+
[,ruby]
|
40
|
+
----
|
41
|
+
gem 'asciidoctor-godoc'
|
42
|
+
----
|
43
|
+
|
44
|
+
Then run the following command:
|
45
|
+
|
46
|
+
....
|
47
|
+
$ bundle install
|
48
|
+
....
|
49
|
+
|
50
|
+
=== With gem
|
51
|
+
|
52
|
+
To install the extension with the gem command,
|
53
|
+
run the following:
|
54
|
+
|
55
|
+
....
|
56
|
+
$ gem install asciidoctor-godoc
|
57
|
+
....
|
58
|
+
|
59
|
+
== Usage
|
60
|
+
|
61
|
+
You may use the extension with the asciidoctor CLI or as a library.
|
62
|
+
|
63
|
+
=== CLI
|
64
|
+
|
65
|
+
To use with the asciidoctor CLI, request the module with `-r`.
|
66
|
+
|
67
|
+
....
|
68
|
+
$ asciidoctor -r asciidoctor-godoc mydoc.adoc
|
69
|
+
....
|
70
|
+
|
71
|
+
=== Library
|
72
|
+
|
73
|
+
To use the extension as a library, require `asciidoctor/godoc`.
|
74
|
+
This will register the extension with asciidoctor.
|
75
|
+
|
76
|
+
.Use via API
|
77
|
+
[,ruby]
|
78
|
+
----
|
79
|
+
require 'asciidoctor'
|
80
|
+
require 'asciidoctor/godoc'
|
81
|
+
|
82
|
+
Asciidoctor.convert_file 'mydoc.adoc'
|
83
|
+
----
|
84
|
+
|
85
|
+
If you don't want the extension automatically registered,
|
86
|
+
import the inline macro implementation manually from
|
87
|
+
`asciidoctor/godoc/inline_macro`.
|
88
|
+
|
89
|
+
.Use with a scoped registry
|
90
|
+
[,ruby]
|
91
|
+
----
|
92
|
+
require 'asciidoctor/extensions'
|
93
|
+
require 'asciidoctor/godoc/inline_macro'
|
94
|
+
|
95
|
+
registry = Asciidoctor::Extensions.create
|
96
|
+
registry.inline_macro Asciidoctor::Godoc::InlineMacro
|
97
|
+
Asciidoctor.convert_file 'mydoc.adoc', extension_registry: registry
|
98
|
+
----
|
99
|
+
|
100
|
+
== Syntax
|
101
|
+
|
102
|
+
The inline macro supports the following formats:
|
103
|
+
|
104
|
+
....
|
105
|
+
godoc:$importPath[$display] // <1>
|
106
|
+
godoc:$importPath#$name[$display] // <2>
|
107
|
+
godoc:$importPath#$name.$child[$display] // <3>
|
108
|
+
....
|
109
|
+
<1> Package reference
|
110
|
+
<2> Top-level entity reference
|
111
|
+
<3> Entity child reference
|
112
|
+
|
113
|
+
Where each of the `$`-variables are:
|
114
|
+
|
115
|
+
[horizontal]
|
116
|
+
importPath:: full import path of a Go package
|
117
|
+
name:: name of a type or function defined in that package
|
118
|
+
subname:: name of a method or field if `$name` references a type
|
119
|
+
display:: text to display -- leave this empty for a default value
|
120
|
+
|
121
|
+
If `$display` is empty, asciidoctor-godoc fills in a default value for it
|
122
|
+
based on the format used.
|
123
|
+
|
124
|
+
[cols="1a,1a"]
|
125
|
+
|====
|
126
|
+
| Format | Default `$display`
|
127
|
+
|
128
|
+
| `godoc:$importPath[$display]`
|
129
|
+
| `$importPath`
|
130
|
+
|
131
|
+
| `godoc:$importPath#$name[$display]`
|
132
|
+
| `$packageName.$name` footnote:[This isn't always accurate. See <<specify-package-name>>.]
|
133
|
+
|
134
|
+
| `godoc:$importPath#$name.$child[$display]`
|
135
|
+
| `$name.$child`
|
136
|
+
|
137
|
+
|====
|
138
|
+
|
139
|
+
NOTE: The default `$display` is an inline literal (`{backtick}...{backtick}`)
|
140
|
+
for all forms except the package reference format.
|
141
|
+
|
142
|
+
.Examples
|
143
|
+
[cols="1a,1a"]
|
144
|
+
|====
|
145
|
+
| Input | Output
|
146
|
+
|
147
|
+
| [,asciidoc]
|
148
|
+
----
|
149
|
+
Check out the godoc:net/http[] package
|
150
|
+
----
|
151
|
+
| Check out the {url-godoc}/net/http[net/http] package
|
152
|
+
|
153
|
+
| [,asciidoc]
|
154
|
+
----
|
155
|
+
For more, click godoc:bytes[here].
|
156
|
+
----
|
157
|
+
| For more, click {url-godoc}/bytes[here].
|
158
|
+
|
159
|
+
| [,asciidoc]
|
160
|
+
----
|
161
|
+
Use godoc:encoding/json#Unmarshal[] to parse JSON.
|
162
|
+
----
|
163
|
+
| Use {url-godoc}/encoding/json#Unmarshal[`json.Unmarshal`] to parse JSON.
|
164
|
+
|
165
|
+
| [,asciidoc]
|
166
|
+
----
|
167
|
+
Use a godoc:encoding/json#Decoder[decoder] to parse JSON from a stream.
|
168
|
+
----
|
169
|
+
| Use a {url-godoc}/encoding/json#Decoder[decoder] to parse JSON from a stream.
|
170
|
+
|
171
|
+
| [,asciidoc]
|
172
|
+
----
|
173
|
+
Set godoc:net/http#Server.Handler[] to your preferred handler.
|
174
|
+
----
|
175
|
+
| Set {url-godoc}/net/http#Server.Handler[`Server.Handler`] to your preferred handler.
|
176
|
+
|
177
|
+
| [,asciidoc]
|
178
|
+
----
|
179
|
+
Pass in the godoc:net/http#Request.Context[request context].
|
180
|
+
----
|
181
|
+
| Pass in the {url-godoc}/net/http#Request.Context[request context].
|
182
|
+
|
183
|
+
|====
|
184
|
+
|
185
|
+
[#specify-package-name]
|
186
|
+
=== Specifying package names
|
187
|
+
|
188
|
+
When using the top-level entity format without display text,
|
189
|
+
e.g. `godoc:net/http#ServeMux[]`,
|
190
|
+
the extension includes the name of the Go package in the generated text,
|
191
|
+
e.g. `http.ServeMux`.
|
192
|
+
|
193
|
+
The name of the package is assumed to be the last component of the import path.
|
194
|
+
|
195
|
+
[cols="1a,1a"]
|
196
|
+
|====
|
197
|
+
| Import path | Assumed package name
|
198
|
+
|
199
|
+
| `github.com/golang/mock/gomock` | `gomock`
|
200
|
+
| `net/http` | `http`
|
201
|
+
| `gopkg.in/yaml.v3` | `yaml.v3` (oops!)
|
202
|
+
| `example.com/client-go` | `client-go` (oops!)
|
203
|
+
|
204
|
+
|====
|
205
|
+
|
206
|
+
As evident by the third and fourth cases,
|
207
|
+
our guess isn't always correct.
|
208
|
+
|
209
|
+
To work around this, the extension supports
|
210
|
+
providing import path to package name mappings
|
211
|
+
with the `gopkgs` attribute.
|
212
|
+
The value of the attribute should be
|
213
|
+
a `;`-separated collection of `$importPath = $packageName` mappings.
|
214
|
+
|
215
|
+
[,asciidoc]
|
216
|
+
----
|
217
|
+
= My document
|
218
|
+
:gopkgs: gopkg.in/yaml.v3 = yaml; example.com/client-go = client
|
219
|
+
----
|
220
|
+
|
221
|
+
Split these across multiple lines by escaping newlines:
|
222
|
+
|
223
|
+
[,asciidoc]
|
224
|
+
----
|
225
|
+
= My document
|
226
|
+
:gopkgs: gopkg.in/yaml.v3 = yaml; \
|
227
|
+
example.com/client-go = client
|
228
|
+
----
|
229
|
+
|
230
|
+
For import paths specified in this mapping,
|
231
|
+
the extension will prefer the provided package name.
|
232
|
+
|
233
|
+
== License
|
234
|
+
|
235
|
+
This software is available as open source
|
236
|
+
under the terms of the https://opensource.org/licenses/MIT[MIT License].
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "asciidoctor"
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << "test"
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Generates the GitHub Pages website"
|
14
|
+
task :site do
|
15
|
+
Asciidoctor.convert_file "README.adoc",
|
16
|
+
to_file: "_site/index.html",
|
17
|
+
standalone: true,
|
18
|
+
mkdirs: true,
|
19
|
+
safe: :safe,
|
20
|
+
attributes: {
|
21
|
+
"source-highlighter" => "rouge",
|
22
|
+
"reproducible" => "true"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubocop/rake_task"
|
27
|
+
|
28
|
+
RuboCop::RakeTask.new
|
29
|
+
|
30
|
+
task default: %i[test rubocop]
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "asciidoctor"
|
4
|
+
require "asciidoctor/extensions"
|
5
|
+
|
6
|
+
module Asciidoctor
|
7
|
+
module Godoc
|
8
|
+
# Provides the 'godoc' inline macro.
|
9
|
+
# This macro allows asciidoc documents to reference
|
10
|
+
# Go packages, types, functions, and methods
|
11
|
+
# with fully-qualified import paths,
|
12
|
+
# and generates links to their reference documentation.
|
13
|
+
class InlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
14
|
+
use_dsl
|
15
|
+
|
16
|
+
named :godoc
|
17
|
+
name_positional_attributes "text"
|
18
|
+
|
19
|
+
def pkgmap(attrs)
|
20
|
+
pkgs = attrs["gopkgs"]
|
21
|
+
return {} unless pkgs
|
22
|
+
|
23
|
+
pkgs.split(/\s*;\s*/).to_h { |e| e.split(/\s*=\s*/) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_text(parent, importpath, id)
|
27
|
+
# For just import paths,
|
28
|
+
# use the import path as-is.
|
29
|
+
return importpath unless id
|
30
|
+
|
31
|
+
if id.split(".").count > 1
|
32
|
+
# If the target is a method or a struct,
|
33
|
+
# use $parent.$target.
|
34
|
+
text = id
|
35
|
+
else
|
36
|
+
# Otherwise use $pkg.$target.
|
37
|
+
pkg = pkgmap(parent.document.attributes)[importpath]
|
38
|
+
pkg ||= importpath.split("/")[-1]
|
39
|
+
text = "#{pkg}.#{id}"
|
40
|
+
end
|
41
|
+
|
42
|
+
node = create_inline parent, :quoted, text, { type: :monospaced }
|
43
|
+
node.convert
|
44
|
+
end
|
45
|
+
|
46
|
+
def process(parent, target, attrs)
|
47
|
+
importpath, id = target.split("#", 2)
|
48
|
+
|
49
|
+
text = attrs["text"] || generate_text(parent, importpath, id)
|
50
|
+
target = %(https://pkg.go.dev/#{importpath})
|
51
|
+
target << "##{id}" if id
|
52
|
+
|
53
|
+
parent.document.register :links, target
|
54
|
+
(create_anchor parent, text, type: :link, target: target).convert.to_s
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asciidoctor-godoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abhinav Gupta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: asciidoctor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 13.0.0
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 13.0.0
|
47
|
+
description: An Asciidoctor extension that adds support for a 'godoc' macro to
|
48
|
+
asciidoc documents. This extension allows referencing Go entities in asciidoc
|
49
|
+
documents, linking to their documentation on https://pkg.go.dev.
|
50
|
+
email:
|
51
|
+
- mail@abhinavg.net
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- ".rubocop.yml"
|
57
|
+
- ".ruby-version"
|
58
|
+
- CHANGELOG.adoc
|
59
|
+
- Gemfile
|
60
|
+
- Gemfile.lock
|
61
|
+
- LICENSE.txt
|
62
|
+
- README.adoc
|
63
|
+
- Rakefile
|
64
|
+
- lib/asciidoctor-godoc.rb
|
65
|
+
- lib/asciidoctor/godoc.rb
|
66
|
+
- lib/asciidoctor/godoc/inline_macro.rb
|
67
|
+
- lib/asciidoctor/godoc/version.rb
|
68
|
+
homepage: https://abhinav.github.io/asciidoctor-godoc/
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata:
|
72
|
+
homepage_uri: https://abhinav.github.io/asciidoctor-godoc/
|
73
|
+
source_code_uri: https://github.com/abhinav/asciidoctor-godoc
|
74
|
+
changelog_uri: https://github.com/abhinav/asciidoctor-godoc/blob/main/CHANGELOG.adoc
|
75
|
+
rubygems_mfa_required: 'true'
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.6.0
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.3.7
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: An Asciidoctor extension to add a 'godoc' macro.
|
95
|
+
test_files: []
|