Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] use pkgcore for eclassdoc -> devbook conversion #317

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
GENTOO_REPO ?= /var/db/repos/gentoo

# Run a single "find" pass to get a list of all files (with the .git
# directory excluded), then filter out what we need.
ALL_FILES := $(shell find . -name .git -prune -o -type f -print)
XMLS := $(filter %/text.xml,$(ALL_FILES))
XMLS := $(filter-out ./eclass-reference/%/text.xml,$(filter %/text.xml,$(ALL_FILES)))
SVGS := $(filter %.svg,$(ALL_FILES))
HTMLS := $(subst text.xml,index.html,$(XMLS))
ECLASS_HTMLS := $(filter ./eclass-reference/%/index.html,$(ALL_FILES))
ALL_ECLASSES := $(shell find $(GENTOO_REPO)/eclass/*.eclass -type f -print)
ECLASS_XMLS := $(patsubst $(GENTOO_REPO)/eclass/%,./eclass-reference/%/text.xml,$(ALL_ECLASSES))
ECLASS_HTMLS := $(subst text.xml,index.html,$(ECLASS_XMLS))
IMAGES := $(patsubst %.svg,%.png,$(SVGS))

CSS_FILES = devmanual.css offline.css
Expand All @@ -21,6 +25,9 @@ OFFLINE = 0
all: prereq validate build documents.js

prereq:
@type pmaint >/dev/null 2>&1 || \
{ echo "sys-apps/pkgcore required" >&2;\
exit 1; }
@type rsvg-convert >/dev/null 2>&1 || \
{ echo "gnome-base/librsvg required" >&2;\
exit 1; }
Expand All @@ -34,7 +41,7 @@ prereq:
{ echo "media-fonts/open-sans is required" >&2;\
exit 1; }

build: $(HTMLS) $(IMAGES)
build: $(HTMLS) $(ECLASS_HTMLS) eclass-reference/index.html $(IMAGES)

# We need to parse all the XMLs every time, not just the ones
# that are newer than the target. This is because each search
Expand All @@ -59,12 +66,11 @@ documents.js: bin/build_search_documents.py $(XMLS)
%.html: $$(dir $$@)text.xml devbook.xsl xsl/*.xsl
xsltproc --param offline "$(OFFLINE)" devbook.xsl $< > $@

eclass-reference/text.xml:
@echo "*** Warning: No eclass documentation found." >&2
@echo "Install app-doc/eclass-manpages and" >&2
@echo "run bin/gen-eclass-html.sh before calling make." >&2
@echo "Creating a placeholder index as fallback." >&2
bin/gen-eclass-html.sh -n
eclass-reference/text.xml: $(ECLASS_XMLS) bin/gen-eclass-html.sh
bin/gen-eclass-html.sh

$(ECLASS_XMLS) &: $(ALL_ECLASSES)
pmaint eclass -f devbook -o "eclass-reference/{eclass}.eclass/text.xml" $^

appendices/todo-list/index.html: $(XMLS)

Expand All @@ -88,7 +94,7 @@ install: all
fi

# Not all versions of xmllint support --quiet, so test for it first
validate: devbook.rng
validate: devbook.rng $(ECLASS_XMLS)
@opt=--quiet; xmllint --help 2>&1 | grep -q -- --quiet || opt=; \
xmllint --noout $${opt} --relaxng $< $(XMLS)
@echo "xmllint validation successful"
Expand Down Expand Up @@ -120,7 +126,7 @@ dist:
git archive --format=tar --prefix=devmanual/ HEAD | xz > $${TARBALL}

clean:
@rm -f $(HTMLS) $(IMAGES) documents.js .depend
@rm -f $(HTMLS) $(IMAGES) $(ECLASS_HTMLS) $(ECLASS_XMLS) documents.js .depend

.PHONY: all prereq build install check validate tidy dist clean

Expand Down
4 changes: 0 additions & 4 deletions bin/gen-eclass-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ shift $((OPTIND-1))

MANPAGES=()
[[ -n ${NOMAN} ]] || MANPAGES=(
$(/usr/bin/qlist -e eclass-manpages)
# We also need a couple of Portage man pages
/usr/share/man/man5/ebuild.5*
/usr/share/man/man5/make.conf.5*
Expand Down Expand Up @@ -163,9 +162,6 @@ for i in "${MANPAGES[@]}"; do
echo -n "${FOOTER}" >> "${FINAL}" || exit 1
done

# Remove old dirs (eclasses that were dropped from the tree)
find "${OUTPUTDIR}" -mindepth 1 -maxdepth 1 -mtime +1 -exec rm -R {} \;

# build the index, rebuilding it each time
cat << 'EOF' > "${OUTPUTDIR}"/text.xml || exit 1
<?xml version="1.0"?>
Expand Down
Loading