Skip to content

Commit

Permalink
this is (most likely) -00
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatsen committed May 24, 2018
0 parents commit 82833f2
Show file tree
Hide file tree
Showing 9 changed files with 946 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .addstyle.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\~</style>~ { a\
<style type="text/css">
r lib/style.css
a\
</style>
}
133 changes: 133 additions & 0 deletions .fold-artwork.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/bin/bash
#
# the only reason why /bin/sh isn't being used
# is because "echo -n" is broken on the Mac.

print_usage() {
echo
echo "Wraps file representing IETF artwork at specified column"
echo "according to BCP XX. Note, this routine does nothing if"
echo "the infile has no lines longer than specified."
echo
echo "Usage: $0 [-r] [-c <col>] -i <infile> -o <outfile>"
echo
echo " -c: column to wrap on (default: 69)"
echo " -r: reverses the operation"
echo " -i: the input filename"
echo " -o: the output filename"
echo " -h: show this message"
echo
echo "Exit status code: zero on success, non-zero otherwise."
echo
}


# global vars, do not edit
reversed=0
infile=""
outfile=""
maxcol=69 # default, may be overridden by param
header="\n[Note: '\' line wrapping for formatting only]\n\n"


fold_it() {
# check if file needs folding
grep ".\{$maxcol\}" $infile >> /dev/null 2>&1
if [ $? -ne 0 ]; then
# nothing to do
cp $infile $outfile
return 1
fi

echo -ne "$header" > $outfile
foldcol=`expr "$maxcol" - 1` # spacer for the inserted '\' char
gsed "s/\(.\{$foldcol\}\)/\1\\\\\n/" < $infile >> $outfile
return 0
}


unfold_it() {
# count lines in header
numlines=`echo -ne "$header" | wc -l`

# check if file needs unfolding
echo -ne "$header" > /tmp/header
head -n $numlines $infile > /tmp/header2
diff -q /tmp/header /tmp/header2 >> /dev/null
code=$?
rm /tmp/header /tmp/header2
if [ $code -ne 0 ]; then
# nothing to do
cp $infile $outfile
return 1
fi

awk "NR>$numlines" $infile > /tmp/wip
gsed ':x; /\\$/ { N; s/\\\n//; tx }' /tmp/wip > $outfile
rm /tmp/wip
return 0
}


process_input() {
while [ "$1" != "" ]; do
if [ "$1" == "-h" -o "$1" == "--help" ]; then
print_usage
exit 1
fi
if [ "$1" == "-c" ]; then
maxcol="$2"
shift
fi
if [ "$1" == "-r" ]; then
reversed=1
fi
if [ "$1" == "-i" ]; then
infile="$2"
shift
fi
if [ "$1" == "-o" ]; then
outfile="$2"
shift
fi
shift
done

if [ -z "$infile" ]; then
echo "error: infile parameter missing."
exit 1
fi

if [ -z "$outfile" ]; then
echo "error: outfile parameter missing."
exit 1
fi

if [ ! -f "$infile" ]; then
echo "error: infile \"$infile\" does not exist."
exit 1
fi

if [ -f "$outfile" ]; then
echo "warning: outfile \"$outfile\" already exists."
fi
}


main() {
if [ "$#" == "0" ]; then
print_usage
exit 1
fi

process_input $@

if [[ $reversed -eq 0 ]]; then
fold_it
else
unfold_it
fi
exit 0
}

main "$@"
33 changes: 33 additions & 0 deletions .insert-figures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# make sure input params are good
if [ "$#" == "0" ]; then
echo "Usage: $0 file[,fold-length]"
exit
fi

cp $1 .tmp.new.txt
while ( grep INSERT_TEXT_FROM_FILE .tmp.new.txt >> /dev/null ); do
i=`grep -n INSERT_TEXT_FROM_FILE .tmp.new.txt | head -1`
linenum=`echo $i | sed 's/:.*//'`
file=`echo $i | sed 's/.*(\(.*\))/\1/'`

awk "NR<$linenum" .tmp.new.txt > .tmp.pre.txt
awk "NR>$linenum" .tmp.new.txt > .tmp.post.txt

if [ `echo $file | grep ","` ]; then
col=`echo $file | sed 's/.*,//'`
file=`echo $file | sed 's/,.*//'`
./.fold-artwork.sh -c $col -i $file -o $file.potentially-folded
else
./.fold-artwork.sh -i $file -o $file.potentially-folded
fi

cat .tmp.pre.txt $file.potentially-folded .tmp.post.txt > .tmp.new.txt
rm $file.potentially-folded
done

cat .tmp.new.txt
rm .tmp.pre.txt .tmp.post.txt .tmp.new.txt


78 changes: 78 additions & 0 deletions .style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@viewport {
zoom: 1.0;
width: extend-to-zoom;
}

@-ms-viewport {
width: extend-to-zoom;
zoom: 1.0;
}

body {
font: 11pt cambria, helvetica, arial, sans-serif;
font-size-adjust: 0.5;
line-height: 130%;
margin: 1em auto;
max-width: 700px;
}

.title, .filename, h1, h2, h3, h4 {
font-family: candara, helvetica, arial, sans-serif;
font-size-adjust: 0.5;
}
.title { font-size: 150%; }
h1 { font-size: 130%; }
h2 { font-size: 120%; }
h3, h4 { font-size: 110%; }
ul.toc >li { font-size: 95%; }
ul.toc >li >ul, .figure, caption { font-size: 90%; }

table {
margin-left: 0em;
}
table.header {
width: 100%;
}

table.header td {
background-color: inherit;
color: black;
}

samp, tt, code, pre {
font: 11pt consolas, monospace;
font-size-adjust: none;
}

pre.text, pre.text2 {
width: 90%;
}

dt {
float: left; clear: left;
margin: 0.5em 0.5em 0 0;
}
dt:first-child {
margin-top: 0;
}
dd {
margin: 0.5em 0 0 2em;
}
dd p, dd ul {
margin-top: 0; margin-bottom: 0;
}
dd *+p {
margin-top: 0.5em;
}

ol, ul {
padding: 0;
margin: 0.5em 0 0.5em 2em;
}
ul.toc, ul.toc ul {
margin: 0 0 0 1.5em;
}
ul.toc a:first-child {
display: inline-block;
min-width: 1.2em;
}
124 changes: 124 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# In case your system doesn't have any of these tools:
# https://pypi.python.org/pypi/xml2rfc
# https://github.com/cabo/kramdown-rfc2629
# https://github.com/Juniper/libslax/tree/master/doc/oxtradoc
# https://tools.ietf.org/tools/idnits/

xml2rfc ?= xml2rfc
kramdown-rfc2629 ?= kramdown-rfc2629
oxtradoc ?= oxtradoc
idnits ?= idnits

draft := $(basename $(lastword $(sort $(wildcard draft-*.xml)) $(sort $(wildcard draft-*.md)) $(sort $(wildcard draft-*.org)) ))

ifeq (,$(draft))
$(warning No file named draft-*.md or draft-*.xml or draft-*.org)
$(error Read README.md for setup instructions)
endif

draft_type := $(suffix $(firstword $(wildcard $(draft).md $(draft).org $(draft).xml) ))

current_ver := $(shell git tag | grep '$(draft)-[0-9][0-9]' | tail -1 | sed -e"s/.*-//")
ifeq "${current_ver}" ""
next_ver ?= 00
else
next_ver ?= $(shell printf "%.2d" $$((1$(current_ver)-99)))
endif
next := $(draft)-$(next_ver)

.PHONY: latest submit clean

#latest: $(draft).txt $(draft).html

default: $(next).xml $(next).txt $(next).html

idnits: $(next).txt
$(idnits) $<

clean:
-rm -f $(draft).txt $(draft).html index.html
-rm -f $(next).txt $(next).html
-rm -f $(draft)-[0-9][0-9].xml
-rm -f ietf-crypto-types\@20*.yang
ifeq (md,$(draft_type))
-rm -f $(draft).xml
endif
ifeq (org,$(draft_type))
-rm -f $(draft).xml
endif

$(next).xml: $(draft).xml
sed -e"s/$(basename $<)-latest/$(basename $@)/" -e"s/YYYY-MM-DD/$(shell date +%Y-%m-%d)/" $< > $@
sed -e"s/YYYY-MM-DD/$(shell date +%Y-%m-%d)/" ietf-crypto-types.yang > ietf-crypto-types\@$(shell date +%Y-%m-%d).yang
cd refs; ./validate-all.sh; ./gen-trees.sh; cd ..;
./.insert-figures.sh $@ > tmp; mv tmp $@
rm refs/*-tree.txt

.INTERMEDIATE: $(draft).xml
%.xml: %.md
$(kramdown-rfc2629) $< > $@

%.xml: %.org
$(oxtradoc) -m outline-to-xml -n "$@" $< > $@

%.txt: %.xml
$(xml2rfc) $< -o $@ --text

ifeq "$(shell uname -s 2>/dev/null)" "Darwin"
sed_i := sed -i ''
else
sed_i := sed -i
endif

%.html: %.xml
$(xml2rfc) $< -o $@ --html
$(sed_i) -f .addstyle.sed $@


### Below this deals with updating gh-pages

GHPAGES_TMP := /tmp/ghpages$(shell echo $$$$)
.TRANSIENT: $(GHPAGES_TMP)
ifeq (,$(TRAVIS_COMMIT))
GIT_ORIG := $(shell git branch | grep '*' | cut -c 3-)
else
GIT_ORIG := $(TRAVIS_COMMIT)
endif

# Only run upload if we are local or on the master branch
IS_LOCAL := $(if $(TRAVIS),,true)
ifeq (master,$(TRAVIS_BRANCH))
IS_MASTER := $(findstring false,$(TRAVIS_PULL_REQUEST))
else
IS_MASTER :=
endif

index.html: $(draft).html
cp $< $@

ghpages: index.html $(draft).txt
ifneq (,$(or $(IS_LOCAL),$(IS_MASTER)))
mkdir $(GHPAGES_TMP)
cp -f $^ $(GHPAGES_TMP)
git clean -qfdX
ifeq (true,$(TRAVIS))
git config user.email "[email protected]"
git config user.name "Travis CI Bot"
git checkout -q --orphan gh-pages
git rm -qr --cached .
git clean -qfd
git pull -qf origin gh-pages --depth=5
else
git checkout gh-pages
git pull
endif
mv -f $(GHPAGES_TMP)/* $(CURDIR)
git add $^
if test `git status -s | wc -l` -gt 0; then git commit -m "Script updating gh-pages."; fi
ifneq (,$(GH_TOKEN))
@echo git push https://github.com/$(TRAVIS_REPO_SLUG).git gh-pages
@git push https://$(GH_TOKEN)@github.com/$(TRAVIS_REPO_SLUG).git gh-pages
endif
-git checkout -qf "$(GIT_ORIG)"
-rm -rf $(GHPAGES_TMP)
endif
Loading

0 comments on commit 82833f2

Please sign in to comment.