asciidoctor-foodogsquared-extensions 1.0.1 → 1.2.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 +4 -4
- data/CHANGELOG.adoc +52 -0
- data/asciidoctor-foodogsquared-extensions.gemspec +3 -1
- data/lib/asciidoctor/foodogsquared/converter.rb +31 -0
- data/lib/asciidoctor/foodogsquared/extensions/chat-block.rb +26 -0
- data/lib/asciidoctor/foodogsquared/extensions/fdroid-inline-macro.rb +28 -0
- data/lib/asciidoctor/foodogsquared/extensions/flathub-inline-macro.rb +35 -0
- data/lib/asciidoctor/foodogsquared/extensions/git-blob-include-processor.rb +68 -0
- data/lib/asciidoctor/foodogsquared/extensions/github-include-processor.rb +70 -0
- data/lib/asciidoctor/foodogsquared/extensions/github-inline-macro.rb +38 -0
- data/lib/asciidoctor/foodogsquared/extensions/gitlab-include-processor.rb +60 -0
- data/lib/asciidoctor/foodogsquared/extensions/gitlab-inline-macro.rb +39 -0
- data/lib/asciidoctor/foodogsquared/extensions/ietf-rfc-inline-macro.rb +18 -0
- data/lib/asciidoctor/foodogsquared/extensions/man-inline-macro.rb +54 -0
- data/lib/asciidoctor/foodogsquared/extensions/musicbrainz-inline-macro.rb +47 -0
- data/lib/asciidoctor/foodogsquared/extensions/package-indices-macro.rb +58 -0
- data/lib/asciidoctor/foodogsquared/extensions/repology-inline-macro.rb +20 -0
- data/lib/asciidoctor/foodogsquared/extensions/swhid-include-processor.rb +55 -0
- data/lib/asciidoctor/foodogsquared/extensions/swhid-inline-macro.rb +28 -0
- data/lib/asciidoctor/foodogsquared/extensions/wikipedia-inline-macro.rb +23 -0
- data/lib/asciidoctor/foodogsquared/extensions.rb +56 -0
- data/lib/asciidoctor/foodogsquared/helpers.rb +26 -0
- data/lib/asciidoctor-foodogsquared-extensions.rb +2 -1
- metadata +35 -35
- data/lib/asciidoctor/chat-block-processor/README.adoc +0 -115
- data/lib/asciidoctor/chat-block-processor/extension.rb +0 -57
- data/lib/asciidoctor/fdroid-link-inline-macro/README.adoc +0 -36
- data/lib/asciidoctor/fdroid-link-inline-macro/extension.rb +0 -28
- data/lib/asciidoctor/flathub-link-inline-macro/README.adoc +0 -28
- data/lib/asciidoctor/flathub-link-inline-macro/extension.rb +0 -35
- data/lib/asciidoctor/foodogsquared-extensions.rb +0 -56
- data/lib/asciidoctor/git-blob-include-processor/README.adoc +0 -68
- data/lib/asciidoctor/git-blob-include-processor/extension.rb +0 -79
- data/lib/asciidoctor/github-link-inline-macro/README.adoc +0 -49
- data/lib/asciidoctor/github-link-inline-macro/extension.rb +0 -36
- data/lib/asciidoctor/github-raw-content-include-processor/README.adoc +0 -40
- data/lib/asciidoctor/github-raw-content-include-processor/extension.rb +0 -68
- data/lib/asciidoctor/gitlab-link-inline-macro/README.adoc +0 -37
- data/lib/asciidoctor/gitlab-link-inline-macro/extension.rb +0 -31
- data/lib/asciidoctor/gitlab-raw-content-include-processor/README.adoc +0 -44
- data/lib/asciidoctor/gitlab-raw-content-include-processor/extension.rb +0 -66
- data/lib/asciidoctor/helpers.rb +0 -20
- data/lib/asciidoctor/ietf-rfc-link-inline-macro/README.adoc +0 -27
- data/lib/asciidoctor/ietf-rfc-link-inline-macro/extension.rb +0 -16
- data/lib/asciidoctor/man-inline-macro/README.adoc +0 -51
- data/lib/asciidoctor/man-inline-macro/extension.rb +0 -45
- data/lib/asciidoctor/musicbrainz-link-inline-macro/README.adoc +0 -45
- data/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb +0 -47
- data/lib/asciidoctor/package-indices-link-macro/extension.rb +0 -56
- data/lib/asciidoctor/repology-link-inline-macro/README.adoc +0 -27
- data/lib/asciidoctor/repology-link-inline-macro/extension.rb +0 -18
- data/lib/asciidoctor/swhid-include-processor/README.adoc +0 -44
- data/lib/asciidoctor/swhid-include-processor/extension.rb +0 -53
- data/lib/asciidoctor/swhid-inline-macro/README.adoc +0 -54
- data/lib/asciidoctor/swhid-inline-macro/extension.rb +0 -26
- data/lib/asciidoctor/wikipedia-inline-macro/README.adoc +0 -30
- data/lib/asciidoctor/wikipedia-inline-macro/extension.rb +0 -21
@@ -1,68 +0,0 @@
|
|
1
|
-
= Git blob include processor
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
An include processor that includes content from the current Git repo.
|
6
|
-
The use case for this is specifically for creating dedicated branches for certain content.
|
7
|
-
|
8
|
-
|
9
|
-
== Synopsis
|
10
|
-
|
11
|
-
[source, asciidoc]
|
12
|
-
----
|
13
|
-
include::git:$REVSPEC[]
|
14
|
-
----
|
15
|
-
|
16
|
-
Where `$REVSPEC` is a revision as specified in link:https://manpages.debian.org/gitrevisions.7[gitrevisions.7].
|
17
|
-
Take note this include processor only accepts a blob object's content to be extracted.
|
18
|
-
This is meant to be used with other attributes.
|
19
|
-
See <<Attributes>> for more details.
|
20
|
-
|
21
|
-
If the resulting operation ends in an error (i.e., non-existing revision, file, something went wrong), it should log a warning and transclude an error.
|
22
|
-
|
23
|
-
|
24
|
-
== Attributes
|
25
|
-
|
26
|
-
- `path` is the filepath to be retrieved from the revision.
|
27
|
-
When used with `diff`, it changes into a semicolon-delimited (`;`) list of files to make diffs with multiple files.
|
28
|
-
|
29
|
-
- `context-lines` is the number of surrounding lines for the diff.
|
30
|
-
This is only effective if `diff` option is given.
|
31
|
-
|
32
|
-
- `other` is the other commit to be compared with.
|
33
|
-
This is only effective if `diff` option is given.
|
34
|
-
|
35
|
-
- `lines` get the specified lines from the path.
|
36
|
-
It uses the same parser as the line specifier from link:https://docs.asciidoctor.org/asciidoc/latest/verbatim/highlight-lines/[highlighting select lines] so the syntax is the same.
|
37
|
-
|
38
|
-
There's also a couple of link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options] for this component.
|
39
|
-
You can give the following options through `opts` attribute (i.e., `opts="diff,reverse"`).
|
40
|
-
|
41
|
-
- `diff` will show the difference in link:https://en.wikipedia.org/wiki/Diff[diff] format.
|
42
|
-
|
43
|
-
- `reverse` reverses the sides to be compared.
|
44
|
-
|
45
|
-
|
46
|
-
== Extra notes
|
47
|
-
|
48
|
-
The extension is composed of two parts: an include processor and a preprocessor.
|
49
|
-
|
50
|
-
The preprocessor add a document attribute, `doccontentref`, which it gives the Git reference for that content.
|
51
|
-
`doccontentref` is the difference between the process working directory (`Dir.pwd`) and the base directory of the content to be converted.
|
52
|
-
In case the process working directory is not entirely consistent for several reasons, you could give the attribute `rootdir` as the basis for the comparison.
|
53
|
-
As another option, you could also manually set `doccontentref` in case it isn't applicable (i.e., for multilingual sites in Hugo projects).
|
54
|
-
|
55
|
-
The include processor also accepts an empty target with the prefix (i.e., `include::git:[]`) as a shorthand for `include::git:{doccontentref}`.
|
56
|
-
|
57
|
-
|
58
|
-
== Example usage
|
59
|
-
|
60
|
-
The following examples assume that `doccontentref` points to `content/posts/sample`.
|
61
|
-
|
62
|
-
- `include::git:HEAD[path=shell.nix]` should transclude the current iteration of `shell.nix`.
|
63
|
-
|
64
|
-
- `include::git:{doccontentref}[opts="diff", path=Gemfile]` should include a diff of the Gemfile from `content/posts/sample` branch (assuming that Gemfile has changed).
|
65
|
-
|
66
|
-
- `include::git:non-existing-rev[opts="diff"]` should result in a warning with the non-existing revision.
|
67
|
-
|
68
|
-
- `include::git:{doccontentref}[path=README, lines=2..5]` should transclude the README file from lines 2-5.
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rugged'
|
4
|
-
|
5
|
-
class GitBlobIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
6
|
-
def handles?(target)
|
7
|
-
target.start_with? 'git:'
|
8
|
-
end
|
9
|
-
|
10
|
-
def process(doc, reader, target, attrs)
|
11
|
-
repo = Rugged::Repository.discover(__dir__)
|
12
|
-
|
13
|
-
git_object_ref = target.delete_prefix 'git:'
|
14
|
-
git_object_ref = doc.attributes['doccontentref'] if git_object_ref.empty?
|
15
|
-
|
16
|
-
begin
|
17
|
-
git_object = repo.rev_parse git_object_ref
|
18
|
-
|
19
|
-
if attrs.key? 'diff-option'
|
20
|
-
options = {}
|
21
|
-
|
22
|
-
options[:paths] = attrs['path'].split(';') if attrs.key? 'path'
|
23
|
-
options[:context_lines] = attrs['context-lines'] if attrs.key? 'context-lines'
|
24
|
-
options[:reverse] = true if attrs.key? 'reverse-option'
|
25
|
-
|
26
|
-
if attrs.key? 'other'
|
27
|
-
other = repo.rev_parse attrs['other'] || nil
|
28
|
-
reader.push_include git_object.diff(other, **options).patch
|
29
|
-
else
|
30
|
-
reader.push_include git_object.diff(**options).patch
|
31
|
-
end
|
32
|
-
else
|
33
|
-
inner_entry = case git_object.type
|
34
|
-
when :blob
|
35
|
-
git_object
|
36
|
-
when :commit
|
37
|
-
git_object.tree.path attrs['path']
|
38
|
-
when :tree
|
39
|
-
git_object.path attrs['path']
|
40
|
-
when :tag
|
41
|
-
git_object.target.tree.path attrs['path']
|
42
|
-
end
|
43
|
-
|
44
|
-
content = repo.lookup(inner_entry[:oid]).content
|
45
|
-
|
46
|
-
if attrs.key? 'lines'
|
47
|
-
content_lines = content.lines
|
48
|
-
new_content = +''
|
49
|
-
doc.resolve_lines_to_highlight(content, attrs['lines']).each do |line_no|
|
50
|
-
new_content << content_lines.at(line_no - 1)
|
51
|
-
end
|
52
|
-
|
53
|
-
content = new_content
|
54
|
-
end
|
55
|
-
|
56
|
-
reader.push_include content
|
57
|
-
end
|
58
|
-
rescue StandardError => e
|
59
|
-
reader.push_include "Unresolved directive for '#{target}' with the following error:\n#{e}"
|
60
|
-
warn e
|
61
|
-
end
|
62
|
-
|
63
|
-
reader
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class GitContentBranchAttributePreprocessor < Asciidoctor::Extensions::Preprocessor
|
68
|
-
def process(document, reader)
|
69
|
-
base_dir = Pathname.new(document.base_dir)
|
70
|
-
rootdir = if document.attributes['rootdir'].nil?
|
71
|
-
Dir.pwd
|
72
|
-
else
|
73
|
-
document.attributes['rootdir']
|
74
|
-
end
|
75
|
-
|
76
|
-
document.attributes['doccontentref'] = base_dir.relative_path_from(rootdir).to_s
|
77
|
-
reader
|
78
|
-
end
|
79
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
= GitHub link inline macro
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
An inline macro that easily links repositories from GitHub.
|
6
|
-
|
7
|
-
|
8
|
-
== Synopsis
|
9
|
-
|
10
|
-
[source, asciidoc]
|
11
|
-
----
|
12
|
-
github:$OWNER/$REPO[$CAPTION]
|
13
|
-
----
|
14
|
-
|
15
|
-
If caption is missing, the link text will be the namespace (i.e., `$OWNER/$REPO`) of the repo.
|
16
|
-
|
17
|
-
|
18
|
-
== Attributes
|
19
|
-
|
20
|
-
There are optional attributes for this macro.
|
21
|
-
|
22
|
-
- `rev` is the commit/branch/tag of the repo to be linked.
|
23
|
-
When given no caption, it will update the default caption with `$OWNER/$REPO@$REV`.
|
24
|
-
|
25
|
-
- `path` is the filepath to be linked within the repo.
|
26
|
-
|
27
|
-
- `issue` accepts the issue number to be linked in the GitHub repo.
|
28
|
-
Take note `issue` is exclusive to other attributes and has more precedence.
|
29
|
-
For example, if `issue` and `rev` are both present, the link for issue will be the result.
|
30
|
-
+
|
31
|
-
When given no caption, it will update the default caption with `$OWNER/$REPO#$ISSUE`.
|
32
|
-
|
33
|
-
You can also change certain behaviors with the link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options attribute].
|
34
|
-
|
35
|
-
- `repo` sets the default link text with only the repo.
|
36
|
-
Pretty useful to quickly refer to the name of the software.
|
37
|
-
|
38
|
-
|
39
|
-
== Example usage
|
40
|
-
|
41
|
-
- `github:foo-dogsquared/website[]` will link to link:https://github.com/foo-dogsquared/website[my website repository] with the link text `foo-dogsquared/website`.
|
42
|
-
|
43
|
-
- `github:NixOS/nixpkgs[nixpkgs nixos-unstable branch, rev=nixos-unstable]` should link to the link:https://github.com/NixOS/nixpkgs/tree/nixos-unstable[NixOS unstable branch of nixpkgs] with a caption of `nixpkgs nixos-unstable branch`.
|
44
|
-
|
45
|
-
- `github:errata-ai/vale[Vale v2.3.0 README, path=README.md, rev=v2.3.0]` should link to the link:https://github.com/errata-ai/vale/blob/v2.3.0/README.md[README of Vale v2.3.0].
|
46
|
-
|
47
|
-
- `github:neovim/neovim[Neovim cannot open large files properly, issue=614]` should link to https://github.com/neovim/neovim/issues/614[an issue of Neovim] with `Neovim cannot open large files properly` as the link text.
|
48
|
-
|
49
|
-
- `github:neovim/neovim[Neovim cannot open large files properly, issue=614, rev=master]` should still link to https://github.com/neovim/neovim/issues/614[an issue of Neovim] since `issue` has more precedence over `rev`.
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
class GitHubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
6
|
-
use_dsl
|
7
|
-
|
8
|
-
named :github
|
9
|
-
name_positional_attributes 'caption'
|
10
|
-
|
11
|
-
def process(parent, target, attrs)
|
12
|
-
doc = parent.document
|
13
|
-
|
14
|
-
default_caption = if attrs.key?('repo-option')
|
15
|
-
target.split('/').at(1)
|
16
|
-
else
|
17
|
-
target
|
18
|
-
end
|
19
|
-
text = attrs['caption'] || default_caption
|
20
|
-
uri = URI.parse %(https://github.com/#{target})
|
21
|
-
|
22
|
-
if attrs.key? 'issue'
|
23
|
-
uri.path += %(/issues/#{attrs['issue']})
|
24
|
-
text << "##{attrs['issue']}" if text == target
|
25
|
-
else
|
26
|
-
uri.path += %(/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
27
|
-
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
28
|
-
text << "@#{attrs['rev']}" if attrs.key?('rev') && text == target
|
29
|
-
end
|
30
|
-
|
31
|
-
target = uri.to_s
|
32
|
-
|
33
|
-
doc.register :links, target
|
34
|
-
create_anchor parent, text, type: :link, target: target
|
35
|
-
end
|
36
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
= GitHub raw content include processor
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
This is a link:https://docs.asciidoctor.org/asciidoctor/latest/extensions/include-processor/[include processor] for easily including files from GitHub.
|
6
|
-
Take note this will only include files.
|
7
|
-
For directories, submodules, or symlinks: they will not be processed and a warning will be issued.
|
8
|
-
|
9
|
-
This extension honors the link:https://docs.asciidoctor.org/asciidoctor/latest/safe-modes/[safe mode setting] and link:https://docs.asciidoctor.org/asciidoc/latest/directives/include-uri/[the prerequisites for permitting includes with URI].
|
10
|
-
|
11
|
-
The following is the basic form of using this include processor.
|
12
|
-
|
13
|
-
[source, asciidoc]
|
14
|
-
----
|
15
|
-
\include::github:$OWNER/$REPO[]
|
16
|
-
----
|
17
|
-
|
18
|
-
|
19
|
-
== Extra notes
|
20
|
-
|
21
|
-
The include processor will use GitHub API.
|
22
|
-
It can create authorized requests by setting a token in `GITHUB_API_BEARER_TOKEN` environment variable.
|
23
|
-
For instructions on how to get a token, you can refer to link:https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api?apiVersion=2022-11-28#authenticating[respective documentation].
|
24
|
-
|
25
|
-
|
26
|
-
== Attributes
|
27
|
-
|
28
|
-
- `path` for the path of the file to be included.
|
29
|
-
This is practically required as the root entry of the repository is a directory.
|
30
|
-
|
31
|
-
- `rev` is the name of the commit/tag/branch to be checked out.
|
32
|
-
|
33
|
-
|
34
|
-
== Example usage
|
35
|
-
|
36
|
-
- `include::github:asciidoctor/asciidoctor[path=README.adoc, rev=v2.0.0]` will include the Asciidoc file from the link:https://github.com/asciidoctor/asciidoctor/[Asciidoctor GitHub repo] from the point of `v2.0.0`.
|
37
|
-
|
38
|
-
- `include::github:NixOS/nixpkgs[path=shell.nix]` will get the latest revision of `shell.nix` from link:https://github.com/NixOS/nixpkgs[nixpkgs repository].
|
39
|
-
|
40
|
-
- `include::github:foo-dogsquared/nixos-config[]` should not be processed considering it points to the root directory of the repository.
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'json'
|
5
|
-
require 'open-uri'
|
6
|
-
require 'uri'
|
7
|
-
|
8
|
-
class GitHubRawIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
9
|
-
def handles?(target)
|
10
|
-
target.start_with? 'github:'
|
11
|
-
end
|
12
|
-
|
13
|
-
def warn_or_raise(doc, warning)
|
14
|
-
if (doc.safe > Asciidoctor::SafeMode::SERVER) && !(doc.attr? 'allow-uri-read')
|
15
|
-
raise warning
|
16
|
-
else
|
17
|
-
warn warning
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def process(doc, reader, target, attrs)
|
22
|
-
src = target.delete_prefix('github:').split('/', 3)
|
23
|
-
owner = src.at 0
|
24
|
-
repo = src.at 1
|
25
|
-
namespaced_repo = "#{owner}/#{repo}"
|
26
|
-
|
27
|
-
path = attrs['path'] || ''
|
28
|
-
|
29
|
-
# For more information, see https://docs.github.com/en/rest/repos/contents.
|
30
|
-
uri = URI.parse %(https://api.github.com/repos/#{owner}/#{repo}/contents/#{path})
|
31
|
-
|
32
|
-
if attrs['rev']
|
33
|
-
query = { ref: attrs['rev'] }
|
34
|
-
uri.query = URI.encode_www_form query
|
35
|
-
end
|
36
|
-
|
37
|
-
begin
|
38
|
-
headers = {
|
39
|
-
'Header' => 'application/vnd.github+json',
|
40
|
-
'X-GitHub-Api-Version' => '2022-11-28'
|
41
|
-
}
|
42
|
-
|
43
|
-
headers['Authorization'] = "Token #{ENV['GITHUB_API_BEARER_TOKEN']}" if ENV['GITHUB_API_BEARER_TOKEN']
|
44
|
-
|
45
|
-
OpenURI.open_uri(uri, headers) do |f|
|
46
|
-
response = JSON.parse(f.read)
|
47
|
-
|
48
|
-
# If the response is an array, it is likely to be a directory. In this
|
49
|
-
# usecase, we'll just list them.
|
50
|
-
content = if response.is_a? Array
|
51
|
-
warning = %(given path '#{path}' from GitHub repo '#{repo}' is a directory)
|
52
|
-
warn_or_raise doc, warning
|
53
|
-
warning
|
54
|
-
elsif response.is_a? Object
|
55
|
-
Base64.decode64 response['content'] if response['content'] && response['encoding'] == 'base64'
|
56
|
-
end
|
57
|
-
|
58
|
-
reader.push_include content, target, target, 1, attrs
|
59
|
-
end
|
60
|
-
rescue OpenURI::HTTPError => e
|
61
|
-
warning = %(error while getting '#{path}' in GitHub repo '#{namespaced_repo}: #{e}')
|
62
|
-
warn_or_raise doc, warning
|
63
|
-
reader.push_include warning, target, target, 1, attrs
|
64
|
-
end
|
65
|
-
|
66
|
-
reader
|
67
|
-
end
|
68
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
= GitLab link inline macro
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
An inline macro for easily linking objects from GitLab instances.
|
6
|
-
|
7
|
-
|
8
|
-
== Synopsis
|
9
|
-
|
10
|
-
[source, asciidoc]
|
11
|
-
----
|
12
|
-
gitlab:$OWNER/$REPO[$CAPTION]
|
13
|
-
----
|
14
|
-
|
15
|
-
|
16
|
-
== Attributes
|
17
|
-
|
18
|
-
- `domain` is the base domain of the GitLab instance.
|
19
|
-
By default, it points to the official instance of `gitlab.com`.
|
20
|
-
|
21
|
-
- `rev` is the commit of the repo.
|
22
|
-
By default. it doesn't point to anything which should be in the default branch of the repository.
|
23
|
-
|
24
|
-
- `path` is the filepath to be linked.
|
25
|
-
|
26
|
-
There are settings that is enabled with the link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options attribute].
|
27
|
-
|
28
|
-
- `repo` sets the default caption to be the repo part.
|
29
|
-
|
30
|
-
|
31
|
-
== Example usage
|
32
|
-
|
33
|
-
- `gitlab:gitlab-org/gitlab[]` will link to link:https://gitlab.com/gitlab-org/gitlab[the GitLab's source code with the default domain].
|
34
|
-
|
35
|
-
- `gitlab:gitlab-org/gitlab[rev=0c9f77389424b6c5fd8e96b227e9125a13a07cb3, path=README.md]` should link to the link:https://gitlab.com/gitlab-org/gitlab/-/blob/0c9f77389424b6c5fd8e96b227e9125a13a07cb3/README.md[GitLab's README from 3 years ago].
|
36
|
-
|
37
|
-
- `gitlab:GNOME/mutter[domain=gitlab.gnome.org, rev=df653b95adf6462fc731998eb53b0860baa7253c, path=meson.build]` should link to link:https://gitlab.gnome.org/GNOME/mutter/-/blob/df653b95adf6462fc731998eb53b0860baa7253c/meson.build[Mutter v44.beta `meson.build` from GNOME GitLab instance].
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
class GitLabLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
6
|
-
use_dsl
|
7
|
-
|
8
|
-
named :gitlab
|
9
|
-
name_positional_attributes 'caption'
|
10
|
-
default_attributes 'domain' => 'gitlab.com'
|
11
|
-
|
12
|
-
def process(parent, target, attrs)
|
13
|
-
doc = parent.document
|
14
|
-
|
15
|
-
default_caption = if attrs.key?('repo-option')
|
16
|
-
target.split('/').at(1)
|
17
|
-
else
|
18
|
-
target
|
19
|
-
end
|
20
|
-
text = attrs['caption'] || default_caption
|
21
|
-
uri = URI.parse %(https://#{attrs['domain']}/#{target})
|
22
|
-
|
23
|
-
uri.path += %(/-/tree/#{attrs['rev']}) if attrs['rev']
|
24
|
-
uri.path += %(/#{attrs['path']}) if attrs['path']
|
25
|
-
|
26
|
-
target = uri.to_s
|
27
|
-
|
28
|
-
doc.register :links, target
|
29
|
-
create_anchor parent, text, type: :link, target: target
|
30
|
-
end
|
31
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
= GitLab raw content include processor
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
It's a link:https://docs.asciidoctor.org/asciidoctor/latest/extensions/include-processor/[include processor] for easily including raw content from GitLab repositories.
|
6
|
-
|
7
|
-
|
8
|
-
== Synopsis
|
9
|
-
|
10
|
-
[source, asciidoc]
|
11
|
-
----
|
12
|
-
include::gitlab/$OWNER/$REPO[rev=$COMMIT, path=$FILEPATH]
|
13
|
-
----
|
14
|
-
|
15
|
-
|
16
|
-
== Extra notes
|
17
|
-
|
18
|
-
A link:https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#personal-access-tokens[personal access token] is most likely required.
|
19
|
-
Get one and place the value in an environment variable `GITLAB_API_PERSONAL_ACCESS_TOKEN`.
|
20
|
-
|
21
|
-
|
22
|
-
== Attributes
|
23
|
-
|
24
|
-
There are some attributes required to be passed.
|
25
|
-
|
26
|
-
- `rev` is the commit to be checked out.
|
27
|
-
- `path` is the file path to be included.
|
28
|
-
|
29
|
-
Aside from the required attributes, there are optional attributes to configured further.
|
30
|
-
|
31
|
-
- `domain` is the domain of the GitLab instance.
|
32
|
-
By default, it points to the `gitlab.com` official instance.
|
33
|
-
|
34
|
-
- `version` is the version string of the API to be used.
|
35
|
-
By default, it uses version `v4`.
|
36
|
-
|
37
|
-
|
38
|
-
== Example usage
|
39
|
-
|
40
|
-
- `include::gitlab:gitlab-org/gitlab[rev=master, path=README.md]` should include the README content from the master branch of link:https://gitlab.com/gitlab-org/gitlab/[GitLab source code].
|
41
|
-
|
42
|
-
- `include::freedesktop-sdk/freedesktop-sdk[rev=bcb3e0de957519e87a4c7b8c0e40af9876e531e7, path=.gitlab-ci.yml]` should transclude the GitLab CI configuration from link:https://gitlab.com/freedesktop-sdk/freedesktop-sdk[Freedesktop SDK].
|
43
|
-
|
44
|
-
- `include::World/warp[domain=gitlab.gnome.org, rev=v0.5.2, path=meson_options.txt]` includes `meson_options.txt` from link:https://gitlab.gnome.org/World/warp/[Warp source code] at v0.5.2.
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'json'
|
5
|
-
require 'open-uri'
|
6
|
-
require 'uri'
|
7
|
-
|
8
|
-
class GitLabRawIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
9
|
-
def handles?(target)
|
10
|
-
target.start_with? 'gitlab:'
|
11
|
-
end
|
12
|
-
|
13
|
-
def warn_or_raise(doc, warning)
|
14
|
-
if (doc.safe > Asciidoctor::SafeMode::SERVER) && !(doc.attr? 'allow-uri-read')
|
15
|
-
raise warning
|
16
|
-
else
|
17
|
-
warn warning
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def process(doc, reader, target, attrs)
|
22
|
-
src = target.delete_prefix('gitlab:').split('/', 2)
|
23
|
-
owner = src.at 0
|
24
|
-
repo = src.at 1
|
25
|
-
namespaced_repo = "#{owner}/#{repo}"
|
26
|
-
|
27
|
-
raise %(there is no 'path' attribute given for GitLab repo '#{namespaced_repo}') unless attrs.key? 'path'
|
28
|
-
raise %(no given ref for getting file in '#{namespaced_repo}') unless attrs.key? 'rev'
|
29
|
-
|
30
|
-
path = attrs['path']
|
31
|
-
rev = attrs['rev']
|
32
|
-
|
33
|
-
domain = attrs['domain'] || 'gitlab.com'
|
34
|
-
version = attrs['version'] || 'v4'
|
35
|
-
|
36
|
-
uri = URI.parse %(https://#{domain}/api/#{version})
|
37
|
-
|
38
|
-
# Set the project.
|
39
|
-
uri += %(/projects/#{URI.encode_www_form_component namespaced_repo})
|
40
|
-
|
41
|
-
# Then the filename.
|
42
|
-
uri += %(/repository/files/#{URI.encode_www_form_component path})
|
43
|
-
|
44
|
-
# Then the revision.
|
45
|
-
query = { ref: rev }
|
46
|
-
uri.query = URI.encode_www_form query
|
47
|
-
|
48
|
-
content = begin
|
49
|
-
headers = { 'Content-Type' => 'application-json' }
|
50
|
-
header['PRIVATE-TOKEN'] = ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN'] if ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN']
|
51
|
-
|
52
|
-
OpenURI.open_uri(uri, headers) do |f|
|
53
|
-
response = JSON.parse(f.read)
|
54
|
-
|
55
|
-
Base64.decode64 response['content'] if response['content'] && response['encoding'] == 'base64'
|
56
|
-
end
|
57
|
-
rescue OpenURI::HTTPError => e
|
58
|
-
warning = %(error while getting '#{path}' in GitLab repo '#{repo}': #{e})
|
59
|
-
warn_or_raise doc, warning
|
60
|
-
warning
|
61
|
-
end
|
62
|
-
|
63
|
-
reader.push_include content, target, target, 1, attrs
|
64
|
-
reader
|
65
|
-
end
|
66
|
-
end
|
data/lib/asciidoctor/helpers.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class String
|
4
|
-
def to_kebab
|
5
|
-
self.gsub(/\s+/, '-') # Replace all spaces with dashes.
|
6
|
-
.gsub(/[^a-zA-Z0-9-]/, '') # Remove all non-alphanumerical (and dashes) characters.
|
7
|
-
.gsub(/-+/, '-') # Reduce all dashes into only one.
|
8
|
-
.gsub(/^-|-+$/, '') # Remove all leading and trailing dashes.
|
9
|
-
.downcase
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module Asciidoctor
|
14
|
-
module FoodogsquaredCustomExtensions
|
15
|
-
NAME = 'asciidoctor-foodogsquared-custom-extensions'
|
16
|
-
VERSION = '1.0.0'
|
17
|
-
CONTACT_EMAIL = 'foodogsquared@foodogsquared.one'
|
18
|
-
USER_AGENT = "#{NAME}/#{VERSION} ( #{CONTACT_EMAIL} )"
|
19
|
-
end
|
20
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
= Flathub link inline macro
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
A shorthand for linking link:https://datatracker.ietf.org/[IETF RFCs].
|
6
|
-
|
7
|
-
|
8
|
-
== Synopsis
|
9
|
-
|
10
|
-
[source, asciidoc]
|
11
|
-
----
|
12
|
-
rfc:$RFC[$CAPTION]
|
13
|
-
----
|
14
|
-
|
15
|
-
Where...
|
16
|
-
|
17
|
-
- `$RFC` is the RFC number.
|
18
|
-
|
19
|
-
- `$CAPTION` is the link text to be used.
|
20
|
-
By default, it will be `RFC$RFC`.
|
21
|
-
|
22
|
-
|
23
|
-
== Example usage
|
24
|
-
|
25
|
-
- `rfc:2136[]` links to the link:https://datatracker.ietf.org/doc/html/rfc2136[RFC2136 (dynamic update)] with the caption `RFC2136`.
|
26
|
-
|
27
|
-
- `rfc:2136[Dynamic DNS updates]` is the same as the previous list item but with the caption text `Dynamic DNS updates`.
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class IETFRFCLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
4
|
-
use_dsl
|
5
|
-
|
6
|
-
named :rfc
|
7
|
-
name_positional_attributes 'caption'
|
8
|
-
|
9
|
-
def process(parent, target, attrs)
|
10
|
-
doc = parent.document
|
11
|
-
url = %(https://datatracker.ietf.org/doc/html/#{target})
|
12
|
-
attrs['caption'] ||= "RFC#{target}"
|
13
|
-
doc.register :links, url
|
14
|
-
create_anchor parent, attrs['caption'], type: :link, target: url
|
15
|
-
end
|
16
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
= Man inline macro
|
2
|
-
:toc:
|
3
|
-
|
4
|
-
|
5
|
-
It's a link:https://docs.asciidoctor.org/asciidoctorj/latest/extensions/inline-macro-processor/[inline macro] that easily links manual pages from an online manpage service like link:https://manpages.debian.org/[Debian Manpages].
|
6
|
-
|
7
|
-
|
8
|
-
== Synopsis
|
9
|
-
|
10
|
-
[source, asciidoc]
|
11
|
-
----
|
12
|
-
man:$MANPAGE[$VOLNUM]
|
13
|
-
----
|
14
|
-
|
15
|
-
|
16
|
-
== Attributes
|
17
|
-
|
18
|
-
There are optional attributes that can be passed.
|
19
|
-
|
20
|
-
- `volnum` expects the section number where the manual page belongs to.
|
21
|
-
This attribute is another way to indicate the section in case you start to use more attributes.
|
22
|
-
The value from `volnum` attribute has higher precedence.
|
23
|
-
When both the positional argument and `volnum` attribute is passed, the `volnum` attribute will be used.
|
24
|
-
|
25
|
-
- `service` is the domain of the online manpage service.
|
26
|
-
Take note this attribute is only used in `html` backend.
|
27
|
-
+
|
28
|
-
--
|
29
|
-
This is an attribute that expects certain values:
|
30
|
-
|
31
|
-
- `debian` uses https://manpages.debian.org.
|
32
|
-
This is also the default service when no value is given.
|
33
|
-
|
34
|
-
- `archlinux` uses https://man.archlinux.org.
|
35
|
-
|
36
|
-
- `opensuse` uses https://manpages.opensuse.org.
|
37
|
-
|
38
|
-
- `voidlinux` use https://man.voidlinux.org.
|
39
|
-
|
40
|
-
- `none` uses none at all. :)
|
41
|
-
This is useful if the reference is not found anywhere.
|
42
|
-
|
43
|
-
Any invalid value raises an error.
|
44
|
-
--
|
45
|
-
|
46
|
-
|
47
|
-
== Example usage
|
48
|
-
|
49
|
-
- `man:crontab[5]` will link to the default manpage service with `crontab(5)` manual page.
|
50
|
-
|
51
|
-
- `man:man[volnum=1, service=archlinux]` will link to the link:https://man.archlinux.org/man/man.1[man manpage] from link:https://man.archlinux.org/[man.archlinux.org].
|