Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
invoke nailing-cargo from the git directory containing the Rust
package you want to build.
-Table of Contents
-=================
-
-
-
-Getting started
-===============
-
Installing
----------
$ nailing-cargo build
```
+Documentation table of contents
+-------------------------------
+
+
Using local crates, or locally modified crates
==============================================
-#!/usr/bin/perl -wni~
+#!/usr/bin/perl -wn
use strict;
use autodie;
our (@doc, @toc);
our $last;
-if (1..m/^Table of Contents/) {
+if (1..(m/^[A-Z]/ && m/table of contents/i)) {
# before TOC
print;
} elsif (m/^\w/..0) {
push @doc, $_;
# after TOC
if (m/^-+$/ || m/^=+$/) {
- my $lev = $& =~ m/^-/ ? ' ' : ' ';
+ my $lev = $& =~ m/^=/ ? ' ' : ' ';
my $href = $last;
- $href =~ y/ A-Z-/-a-z/d;
+ $href =~ y/ A-Z/-a-z/;
+ $href =~ y/-._a-z//cd;
push @toc, "${lev}* [$last](#$href)\n";
}
$last = $_;
chomp $last;
} else {
# in TOC
- print if m/^===/;
+ print if m/^===|^---/;
}
END {
- print @toc;
+ print "\n", @toc, "\n";
print @doc;
}