Skip to content

Commit

Permalink
New subcommand "docinfo"
Browse files Browse the repository at this point in the history
Fixes issue #414
  • Loading branch information
fsundermeyer committed Nov 6, 2023
1 parent b54d62a commit e36dd31
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion bin/daps.in
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ HELP_SUBCOMMAND[dist-webhelp]="Creates a distributable tar archive of a webhelp
SUBCOMMANDS[dist-webhelp-name]="show_names"
HELP_SUBCOMMAND[dist-webhelp-name]="Print the file name that would result when building a distributable tar archive\nof a webhelp document."

SUBCOMMANDS[docinfo]="build_generic"
HELP_SUBCOMMAND[docinfo]="Print information such as title, language, etc on a book or article."

SUBCOMMANDS[epub]="build_epub"
HELP_SUBCOMMAND[epub]="Build an eBook from the XML sources."

Expand Down Expand Up @@ -393,7 +396,7 @@ SUBCOMMANDS[pdf-name]="show_names"
HELP_SUBCOMMAND[pdf-name]="Print the file name that would result when building a grayscale PDF document."

SUBCOMMANDS[productinfo]="build_generic"
HELP_SUBCOMMAND[productinfo]="Print the contents of the tags <productname> and <productnumber for the given ROOTID"
HELP_SUBCOMMAND[productinfo]="Print the contents of the tags <productname> and <productnumber for the given ROOTID."

SUBCOMMANDS[profile]="build_generic"
HELP_SUBCOMMAND[profile]="Create profiled souces from the original XML sources. If the MAIN-file does\nnot contain profiling instructions, link the files into the profile directory."
Expand Down Expand Up @@ -636,6 +639,8 @@ Subcommands:
errors that cannot be found otherwise.
dapsenv Print a list of the most important make variables
and their value.
docinfo Print information such as tTitle, language, etc
on a book or article.
images Generates all images for the given DC-file or
rootid.
showvariable Print value of a given make variable:
Expand Down
19 changes: 19 additions & 0 deletions make/misc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,23 @@ productinfo: $(BIGFILE)
@echo -n "PRODUCTNUMBER=\"$(shell $(XMLSTARLET) sel $(NAMESPACE) -t -v "(/*/*/$(ELEM_PREFIX)productnumber)[1]" $< 2>/dev/null)\""
endif

#---------------
# Bookinfo
#
.PHONY: docinfo
ifeq "$(DOCBOOK_VERSION)" "5"
docinfo: NAMESPACE := -N db5="http://docbook.org/ns/docbook"
docinfo: ELEM_PREFIX := db5:
docinfo: ATTR_PREFIX := xml:
endif
ifdef ROOTID
docinfo: ID_PREF := *[@$(ATTR_PREFIX)id='$(ROOTID)']/*/
endif
docinfo: $(BIGFILE)
@echo -e "Title:\t\t\t$(shell $(XMLSTARLET) sel $(NAMESPACE) -t -v "normalize-space((//$(ID_PREF)$(ELEM_PREFIX)title)[1])" $< 2>/dev/null)"
@echo -e "Product Name:\t\t$(shell $(XMLSTARLET) sel $(NAMESPACE) -t -v "normalize-space((//$(ID_PREF)$(ELEM_PREFIX)productname)[1])" $< 2>/dev/null)"
@echo -e "Product Version:\t$(shell $(XMLSTARLET) sel $(NAMESPACE) -t -v "normalize-space((//$(ID_PREF)$(ELEM_PREFIX)productnumber)[1])" $< 2>/dev/null)"
@echo -e "Authors:\t\t$(shell $(XMLSTARLET) sel $(NAMESPACE) -T -t -m '//$(ID_PREF)$(ELEM_PREFIX)authorgroup' -m '$(ELEM_PREFIX)author' -v 'concat($(ELEM_PREFIX)personname/$(ELEM_PREFIX)firstname, " ", $(ELEM_PREFIX)personname/$(ELEM_PREFIX)surname)' -i 'position() != last()' -o ', ' $< 2>/dev/null)"
@echo -e "Language:\t\t$(XMLLANG)"
@echo -e "Type:\t\t\t$(ROOTELEMENT)"

3 changes: 2 additions & 1 deletion make/selector.mk
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ endif
#---------------
# Miscellaneous
#
MISCTARGETS := bigfile linkcheck stylecheck productinfo

MISCTARGETS := bigfile docinfo linkcheck stylecheck productinfo

ifeq "$(MAKECMDGOALS)" "$(filter $(MAKECMDGOALS),$(MISCTARGETS))"
include $(DAPSROOT)/make/setfiles.mk
Expand Down
1 change: 1 addition & 0 deletions make/setfiles.mk
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ifdef ROOTSTRING
DOCFILES += $(MAIN)
else
DOCFILES := $(SRCFILES)
ROOTELEMENT := $(shell $(XMLSTARLET) sel -t -v "(//div)[1]/@remap" $(SETFILES_TMP) 2>/dev/null)
endif

# Entity files
Expand Down

0 comments on commit e36dd31

Please sign in to comment.