mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
readme: make local file links work relative to out/
Thanks to awesome help at: https://github.com/asciidoctor/asciidoctor/issues/3324
This commit is contained in:
3
Gemfile
Normal file
3
Gemfile
Normal file
@@ -0,0 +1,3 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'asciidoctor', '2.0.10'
|
||||
13
Gemfile.lock
Normal file
13
Gemfile.lock
Normal file
@@ -0,0 +1,13 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
asciidoctor (2.0.10)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
asciidoctor (= 2.0.10)
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.1
|
||||
11
README.adoc
11
README.adoc
@@ -14880,20 +14880,21 @@ Source: link:build-doc[]
|
||||
When running link:build-doc[], we do the following checks:
|
||||
|
||||
* `<<>>` inner links are not broken
|
||||
* `+link:somefile[]+` links point to paths that exist via <<asciidoctor-extract-links>>. Upstream wontfix at: https://github.com/asciidoctor/asciidoctor/issues/3210
|
||||
* `+link:somefile[]+` links point to paths that exist via <<asciidoctor-extract-link-targets>>. Upstream wontfix at: https://github.com/asciidoctor/asciidoctor/issues/3210
|
||||
|
||||
The scripts prints what you have to fix and exits with an error status if there are any errors.
|
||||
|
||||
===== asciidoctor-extract-links
|
||||
[[asciidoctor-extract-link-targets]]
|
||||
===== asciidoctor/extract-link-targets
|
||||
|
||||
Documentation for link:asciidoctor-extract-links[]
|
||||
Documentation for link:asciidoctor/extract-link-targets[]
|
||||
|
||||
Extract link targets from Asciidoctor document.
|
||||
|
||||
Usage:
|
||||
|
||||
....
|
||||
./asciidoctor-extract-links README.adoc
|
||||
./asciidoctor/extract-link-targets README.adoc
|
||||
....
|
||||
|
||||
Output: one link target per line.
|
||||
@@ -14930,7 +14931,7 @@ ls "$(./getvar buildroot_build_dir)"
|
||||
|
||||
Note that host tools like QEMU and gem5 store all archs in a single directory to factor out build objects, so cleaning one arch will clean all of them.
|
||||
|
||||
To only nuke only one Buildroot package, we can use the link:https://buildroot.org/downloads/manual/manual.html#pkg-build-steps[]`-dirclean`] Buildroot target:
|
||||
To only nuke only one Buildroot package, we can use the link:https://buildroot.org/downloads/manual/manual.html#pkg-build-steps[`-dirclean`] Buildroot target:
|
||||
|
||||
....
|
||||
./build-buildroot --no-all -- <package-name>-dirclean
|
||||
|
||||
31
asciidoctor/link-target-up.rb
Normal file
31
asciidoctor/link-target-up.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
=begin
|
||||
README.html links break because we place that output file in out/
|
||||
This extension hacks local link targets to the right path.
|
||||
=end
|
||||
|
||||
require 'asciidoctor'
|
||||
require 'asciidoctor/extensions'
|
||||
|
||||
class Main < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
use_dsl
|
||||
named :link
|
||||
ExternalLinkRegex = /^https?:\/\//
|
||||
def process parent, target, attrs
|
||||
text = attrs[1]
|
||||
if text.nil? || text.empty?
|
||||
text = target
|
||||
end
|
||||
if !ExternalLinkRegex.match?(target)
|
||||
target = File.join('..', target)
|
||||
end
|
||||
create_anchor parent, text, type: :link, target: target
|
||||
end
|
||||
end
|
||||
|
||||
Asciidoctor::Extensions.register do
|
||||
inline_macro Main
|
||||
end
|
||||
|
||||
#(Asciidoctor.load_file(ARGV[0])).convert
|
||||
21
build-doc
21
build-doc
@@ -19,25 +19,22 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentatio
|
||||
)
|
||||
|
||||
def timed_main(self):
|
||||
self.sh.run_cmd(
|
||||
asciidoctor_dir = os.path.join(self.env['root_dir'], 'asciidoctor')
|
||||
exit_status = self.sh.run_cmd(
|
||||
[
|
||||
'asciidoctor', LF,
|
||||
'-o', self.env['readme_out'], LF,
|
||||
'-v', self.env['readme'], LF,
|
||||
'--failure-level', 'info', LF,
|
||||
'--require', os.path.join(asciidoctor_dir, 'link-target-up.rb'), LF,
|
||||
'--out-file', self.env['readme_out'], LF,
|
||||
'--trace', LF,
|
||||
'--verbose', LF,
|
||||
self.env['readme'], LF,
|
||||
],
|
||||
out_file=self.env['build_doc_log'],
|
||||
)
|
||||
error_re = re.compile('^asciidoctor: WARNING: ')
|
||||
exit_status = 0
|
||||
if not self.env['dry_run']:
|
||||
with open(self.env['build_doc_log']) as f:
|
||||
for line in f:
|
||||
if error_re.search(line):
|
||||
exit_status = 1
|
||||
break
|
||||
external_link_re = re.compile('^https?://')
|
||||
for link in subprocess.check_output([
|
||||
os.path.join(self.env['root_dir'], 'asciidoctor-extract-links'),
|
||||
os.path.join(asciidoctor_dir, 'extract-link-targets'),
|
||||
self.env['readme']
|
||||
]).decode().splitlines():
|
||||
if not external_link_re.match(link):
|
||||
|
||||
Reference in New Issue
Block a user