forked from opengeospatial/sensorthings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed table of * generation for newer Asciidoctor versions
- Loading branch information
Showing
1 changed file
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,48 @@ | ||
#!/usr/bin/ruby | ||
require 'asciidoctor' | ||
require 'pp' | ||
|
||
doc = Asciidoctor.load_file(ARGV[0], to_file: false, safe: :unsafe, catalog_assets: true) | ||
|
||
def dumpObj(obj) | ||
obj.instance_variables.map do |var| | ||
type = obj.instance_variable_get(var).class | ||
case type.name | ||
when "String", "Integer" | ||
val = obj.instance_variable_get(var) | ||
else | ||
val = '[undetermined]' | ||
end | ||
print "" , var , " : " , type , " : " , val , "\n" | ||
end | ||
end | ||
|
||
print "// DO NOT EDIT THIS AUTOGENERATED FILE.\n\n" | ||
print "[preface]\n== Table of Figures\n\n" | ||
|
||
figs = doc.references[:ids].keys.find_all { |x| x.start_with? "fig-" } | ||
figs.each do |fig| | ||
print "* <<" + fig + ">> - " + doc.references[:ids][fig].gsub("<code>","`").gsub("</code>","`") + "\n" | ||
refs = doc.references[:refs].keys.find_all { |x| x.start_with? "fig-" } | ||
refs = refs.sort{|a, b| doc.references[:refs][a].numeral <=> doc.references[:refs][b].numeral} | ||
refs.each do |figName| | ||
fig = doc.references[:refs][figName] | ||
print "* <<" + figName + ">> - " + fig.title.gsub("<code>","`").gsub("</code>","`") + "\n" | ||
end | ||
print "\n\n" | ||
|
||
print "\n\n" | ||
print "[preface]\n== Table of Tables\n\n" | ||
|
||
figs = doc.references[:ids].keys.find_all { |x| x.start_with? "tab-" } | ||
figs.each do |fig| | ||
print "* <<" + fig + ">> - " + doc.references[:ids][fig].gsub("<code>","`").gsub("</code>","`") + "\n" | ||
refs = doc.references[:refs].keys.find_all { |x| x.start_with? "tab-" } | ||
refs = refs.sort{|a, b| doc.references[:refs][a].numeral <=> doc.references[:refs][b].numeral} | ||
refs.each do |refName| | ||
ref = doc.references[:refs][refName]; | ||
print "* <<" + refName + ">> - " + ref.title.gsub("<code>","`").gsub("</code>","`") + "\n" | ||
end | ||
print "\n\n" | ||
|
||
print "[preface]\n== Table of Requirements\n\n" | ||
|
||
figs = doc.references[:ids].keys.find_all { |x| x.start_with? "req-" } | ||
figs.each do |fig| | ||
print "* Requirement <<" + fig + ">> - <<requirement-" + fig[4 .. -1] + ">>\n" | ||
refs = doc.references[:refs].keys.find_all { |x| x.start_with? "req-" } | ||
refs = refs.sort{|a, b| Integer(doc.references[:refs][a].reftext) <=> Integer(doc.references[:refs][b].reftext)} | ||
refs.each do |refName| | ||
print "* Requirement <<" + refName + ">> - <<requirement-" + refName[4 .. -1] + ">>\n" | ||
end | ||
print "\n\n" |