Chapter 3. Using the publican package
This chapter describes—the process of installing the publican package, creating books, the main configuration files, example book files, and how to build a book.
Use the create_book
command to create a new book. The create_book
command creates all the necessary files to create a book.
The following is a list of valid options for the create_book
command. Append these options to the end of the create_book
command. For example, create_book --help
, create_book --name New_Book
, and so on:
--help
print a list of all create_book
command options.
--man
view the publican manual page. The manual page contains the same information returned by the create_book --help
command.
--name Book_Name
replace Book_Name
with the name of the book or article. This variable must not contain any spaces. For example, running the create_book --name Test_Book
command creates a book named Test_Book, and all the necessary files to build the book. This updates the Makefile
with the correct DOCNAME
, and the Book_Name
.ent
file with the correct BOOKID
.
--version version
replace
version
with the version number of the product that the book describes. For example, for Red Hat Enterprise Linux 5.1 you would use 5.1. The default version is 0.1. Using
--version version
updates the
<issuenum></issuenum>
tags in the
Book_Info.xml
file. For more information see
Section 3.3.2, “Book_Info.xml”.
--edition edition
replace
edition
with the edition number of the book. This number indicates to users when a new edition of the book is released. The initial GA release of the book should be edition 1.0. The default value is 0. Using
--edition edition
updates the
<edition></edition>
tags in the
Book_Info.xml
file. For more information see
Section 3.3.2, “Book_Info.xml”.
--product Product_Name
replace Product_Name
with the product name. This variable must not contain any spaces. Set this to Fedora
for core Fedora documentation, and the name of the product for other products, for example, Fedora_Directory_Server
. The --product Product_Name
option updates the Makefile
and the Book_Name
.ent
file with the correct product name.
--type Article --name Article_Name
create an article instead of a book. Replace Article_Name
with the article name. This variable must not contain any spaces.
--brand brand
replace
brand
with RedHat, fedora, JBoss, oVirt, or GIMP. This requires the appropriate publican package to be installed. For example, to build Red Hat branded books, you must install the publican-redhat package. See
Section 3.1, “Installing publican” for instructions on installing the branded publican packages. If no brand is specified, the default brand is used.
Before running the create_book
command, use the cd
command to change into the directory where you want the book to be created. For example, to create a book named Test_Book in the /my/books/
directory, run the following commands:
create_book --name Test_Book
To see the results of this command, run the following:
The output should be similar to the following:
3.3. Files in the Book directory
Running the create_book --name Book_Name
command will create a directory structure and the required files, similar to the following:
The Makefile
is used to configure build options, and is located in the root of the book directory. The following is an example Makefile
, with instructions following afterwards:
#Makefile for MYBOOK
XML_LANG = en-US
BRAND = common
#OTHER_LANGS = as-IN bn-IN de-DE es-ES fr-FR gu-IN hi-IN it-IT ja-JP kn-IN ko-KR ml-IN mr-IN or-IN pa-IN pt-BR ru-RU si-LK ta-IN te-IN zh-CN zh-TW
# Extra Parameters start here
# Extra Parameters stop here
COMMON_CONFIG = /usr/share/publican
include $(COMMON_CONFIG)/make/Makefile.common
XML_LANG
set this to the language of the source xml files, for example, en-US
.
BRAND
set the brand of the book. Accepted values are RedHat
, fedora
, JBoss
, oVirt
and GIMP
. If no brand is specified, the default brand is used.
Running the create_book --name Book_Name
--brand brand
command correctly configures the BRAND
.
OTHER_LANGS
space-separated list of other language locales. Used to specify other language locales to build the book in.
The following is an example Makefile
that includes translations:
XML_LANG = en-US
BRAND = RedHat
OTHER_LANGS = as-IN bn-IN de-DE es-ES fr-FR gu-IN hi-IN it-IT ja-JP kn-IN ko-KR ml-IN mr-IN or-IN pa-IN pt-BR ru-RU si-LK ta-IN te-IN zh-CN zh-TW
COMMON_CONFIG = /usr/share/publican
include $(COMMON_CONFIG)/make/Makefile.common
Note
OTHER_LANGS
is no longer commented out.
Note
Run the make help_params
command in the root directory of a book for a full list of parameters that can be set in the Makefile
.
The Book_Info.xml
file contains the key meta-data concerning a book: the book's ID; title; subtitle; author and edition number. It also contains the name and version of the product the book is about and an abstract.
Aside from, as you'd expect, constituting much of a book's front matter, this meta-data is also used when building books as RPMs. Consequently, if you wish to distribute a book as a .rpm file, several of the tags included by default in Book_Info.xml
must have appropriate data within them, and that data must conform to the requirements of the RPM format.
Data from seven of the default tags in Book_Info.xml
is required to build books as RPMs. Most immediately, the file name of a book built as an RPM is constructed as follows: productname
-title
-productnumber
-language
-edition
-pubsnumber
.src.rpm
. Everything but language
above is pulled from Book_Info.xml
. (Language is supplied by the user at make time.) As well, the subtitle
and abstract
are used in the rpm spec file.
An example Book_Info.xml
file, for the Test_Book book, is presented below. Details regarding this file, and what the RPM format requirements are for each tag, follow.
<?xml version='1.0'?>
<!DOCTYPE bookinfo PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<bookinfo id="MYBOOK-MYPRODUCT">
<title>MYBOOKNAME</title>
<subtitle>short descriptor</subtitle>
<productname>MYPRODUCTNAME</productname>
<productnumber>0.0</productnumber>
<edition>0.0</edition>
<pubsnumber>0</pubsnumber>
<abstract>
<para>A short overview and summary of the book's subject and purpose, traditionally no more than one paragraph long. Note: the abstract will appear in the front matter of your book and will also be placed in the #description field of the book's RPM spec file.</para>
</abstract>
<corpauthor>
<inlinemediaobject>
<imageobject>
<imagedata format='SVG' fileref="Common_Content/images/title_logo.svg" />
</imageobject>
<textobject><phrase>Logo</phrase></textobject>
</inlinemediaobject>
</corpauthor>
<copyright>
<year>&YEAR;</year>
<holder>&HOLDER;</holder>
</copyright>
<xi:include href="Common_Content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Author_Group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</bookinfo>
<bookinfo id="book_id
">
The Book ID is used internally and is not displayed to end users when the book is built. If you run the make clean_ids
command, any manually entered ID, including this one, will be changed to a Book_Name-Title
format, where Title
is the title of the associated book, article, section, or chapter.
<productname>productname
</productname>
The name of the product or product stream the book is about (for example: Red Hat Enterprise Linux or JBoss Enterprise Application Platform). When building a book as an RPM, data in the <productname> tag is used as part of the filename of the resultant .rpm file.
Important
Because data in this tag also appears as part of the .rpm filename, this field can only contain upper- and lower-case un-accented letters and the underscore and space characters (ie ‘a–z’, ‘A–Z’ and ‘_’ and ‘ ’).
<title>title
</title>
Obviously enough, the book's title (for example, Server Configuration Guide). The title appears under the product name in both HTML and PDF editions. A title is required to build an RPM. When building a book as an RPM the title is used as the part of the file-name of the RPM package.
Important
Because data in this tag also appears as part of the .rpm filename, this field can only contain upper- and lower-case un-accented letters and the underscore and space characters (ie ‘a–z’, ‘A–Z’ and ‘_’ and ‘ ’).
<subtitle>subtitle
</subtitle>
Again, plainly enough, the subtitle tag contains a book's subtitle: an alternative, and commonly explanatory title for the book (for example: Server Configuration Guide: Preparing Red Hat Enterprise Linux for Production Use). The subtitle appears under the title in both HTML and PDF editions. A subtitle is also required to make a book available as an RPM. When building a book as an RPM, the subtitle is used as the Summary
in the RPM spec file. The rpm -qi
returns the contents of several spec file fields, including the Summary field.
<productnumber>productnumber
</productnumber>
The version number of the product the book covers, for example ‘5.2’ for Red Hat Enterprise Linux 5.2 and ‘4.3’ for JBoss EAP 4.3.
Running the create_book --name Book_Name
--version version
command correctly configures the product number.
Important
Because data in this tag is used in the RPM spec file, this tag can only contain numbers and the full stop or period (ie ‘0–9’ and ‘.’).
<edition>edition
</edition>
This is the edition number of the book. The first edition of the book should be 1.0 (you may like to use 0.y for pre-release versions of a book). Subsequent editions should increment the 1.y to indicate to readers that the book is a new edition. The edition changes the first two digits of the version number in the .rpm filename when building a book with the tar
or srpm
options.
For example, setting the edition to 1.2
and building the book using the make srpm-en-US
command, would create an RPM file named productname
-title
-productnumber
-en-US-1.2-0.src.rpm
.
Running the create_book --name Book_Name
--edition x
.y
command correctly configures the edition.
Important
Because data in this tag sets the Version
in the RPM spec file, this tag can only contain numbers and the full stop or period (ie ‘0–9’ and ‘.’).
<pubsnumber>pubsnumber
</pubsnumber>
The pubsnumber changes the release number (the last digit) when building a book with the tar
or srpm
options. For example, setting the pubsnumber to 1
and building the book using the make srpm-en-US
command, would create an RPM file named productname
-title
-productnumber
-en-US-edition
-1.src.rpm
.
Important
Because data in this tag sets the Release
in the RPM spec file, this tag can only contain numbers (ie ‘0–9’).
<abstract><para>abstract
</para></abstract>
A short overview and summary of the book's subject and purpose, traditionally no more than a paragraph long. The abstract appears before the table of contents in HTML editions and on the second page of PDF editions. When a book is built as an RPM, the abstract sets the Description
field of the RPM's spec file. This makes the abstract for a package available via the rpm -qi
.
3.3.3. RPMs, Editions, Impressions and Versions
As noted above, the default Book_Info.xml used by Publican includes an <edition>
tag.
If you distribute a book as an RPM package, the data placed within this tag sets 'the first two digits of the version number in the .rpm filename'.
So, an edition of '1.0' becomes a version of '1.0'.
Book_Info.xml also includes the <pubsnumber>
tag. Any data placed within this tag changes the release number of RPM-packaged books.
A book with an edition of 1.0 and a pubsnumber of 5, would be version 1.0, release 5 (1.0-5).
The edition and pubsnumber are not tied to the <productnumber>
tag also found in Book_Info.xml: productnumber denotes the version number of the product being documented or otherwise written about.
It is entirely possible to have a 2nd edition of a book pertaining to a particular version of a product.
In Bibliography, two copies of a book are the same edition if they are printed using substantially the same type-set master plates or pages. ('Substantially' offers some wiggle room for typo corrections and the like.)
Book collectors routinely conflate 'first edition' with 'first print run', while Bibliographers pay attention to the text commonly placed in the front matter of a book, which calls a 2nd print run off the same (or substantially the same) plates a '1st edition, 2nd impression' or '1st edition, 2nd printing'.
We recommend following Bibliographic practice in this regard. When using Publican to re-publish a book from 'substantially the same XML', increment the <pubsnumber>
tag, not the <edition>
tag. It functions as a near-equivalent to the impression or printing number of traditional publishing.
As for changing the Edition number, we recommend changing this in the same circumstances traditional publishers change the edition of a work: when it is revised and re-written significantly. What constitutes significant, and how much re-writing is needed to increment an Edition number by a whole number and how much is needed to increment it by one-tenth of a whole number, is a matter of editorial discretion.
Author_Group.xml
is not required but is the standard place to record author, editor, artist and other credit details. The following is an example Author_Group.xml
file:
<?xml version='1.0'?>
<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<authorgroup>
<corpauthor>FF0000 Headgear Documentation Group</corpauthor>
<author>
<firstname>Dude</firstname>
<surname>McDude</surname>
<affiliation>
<orgname>My Org</orgname>
<orgdiv>Best Div in the place</orgdiv>
</affiliation>
<email>dude.mcdude@myorg.org</email>
</author>
</authorgroup>
Author_Group.xml
does not have to contain all of the above information: include as much or as little as required.
If you do not want or need Author_Group.xml
included in a book, delete the following line from Book_Info.xml
before building:
<xi:include href="Author_Group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
The Chapter.xml
file is a template for creating chapter files. Chapter files contain the content that make up a book. The following is a chapter template (Chapter.xml
) that is created after running the create_book
command. Note the DOCTYPE
is set to chapter
:
<?xml version='1.0'?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<chapter id="MYBOOK-Test">
<title>Test</title>
<para>
This is a test paragraph
</para>
<section id="MYBOOK-Test-Section_1_Test">
<title>Section 1 Test</title>
<para>
Test of a section
</para>
</section>
<section id="MYBOOK-Test-Section_2_Test">
<title>Section 2 Test</title>
<para>
Test of a section
</para>
</section>
</chapter>
Note
The chapter file should be renamed to reflect the chapter subject. For example, a chapter on product installation could be named Installation.xml
, whereas a chapter on setting up a piece of software would be better called Setup.xml
or Configuration.xml
.
The Book_Name
.xml
file contains xi:include
directives to include the chapters for a book. Chapters are contained in separate XML files, and the Book_Name
.xml
file brings them together into a single book.
The following is an example Book_Name
.xml
file. Note the DOCTYPE
is set to book
.
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<book>
<xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Chapter.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<index />
</book>
This example loads the Book_Info.xml
, Preface.xml
, Chapter.xml
, and Appendix.xml
XML files.
Important
The order in which chapters are listed matters. When this example book is built, Book_Info.xml will precede Preface.xml which will precede Chapter.xml, and so on.
The Book_Name
.xml
file is not limited to using xi:include
directives. Books can be created using a single XML file. The following is an example of a book created using a single XML file:
<book>
<chapter>
<title>Chapter 1</title>
<para>
A paragraph in Chapter 1.
</para>
<section id="section1">
<title>Chapter 1 Section 1</title>
<para>
A paragraph in Section 1.
</para>
</section>
<section id="section2">
<title>Chapter 1 Section 2</title>
<para>
A paragraph in Section 2.
</para>
</section>
</chapter>
<chapter>
<title>Chapter 2</title>
<para>
A paragraph in Chapter 2.
</para>
</chapter>
</book>
The Book_Name
.ent
file is used to define local entities. The YEAR
and HOLDER
entities are used for copyright information. You must define YEAR
and HOLDER
entities, otherwise the book will not build:
<!ENTITY PRODUCT "MYPRODUCT">
<!ENTITY BOOKID "MYBOOK">
<!ENTITY YEAR "2008">
<!ENTITY HOLDER "YOUR NAME GOES HERE">
Important
Entities offer convenience but they should be used with extreme caution. Writing (for example) &FDS;
instead of Fedora Directory Server saves the writer time but transformed entities do not appear in .po
files. Complete translations of documents containing entities are, as a consequence, impossible.
If you define an entity — <!ENTITY LIFT "Liberty Installation and Formatting Tome">
— you can enter &LIFT;
in your XML and it will appear as The Secret to Eternal Life every time the book is built to HTML, PDF or Text.
Entities are not transformed when XML is converted to PO, however. Which means translators never see Liberty Installation and Formatting Tome. Instead they see &LIFT;
, which they cannot translate.
Consider something as simple as the following English sentence fragment being translated into a related language: German.
As noted in the Liberty Installation and Formatting Tome, Chapter 3…
A translation of this might be as follows:
Wie in dem Wälzer für die Installation und Formatierung von Liberty, Kapitel 3, erwähnt…
Because there is no text missing, the title can be translated into elegant German, avoiding the multi-syllabic mega-word syndrome. Also, note the use of ‘in dem’, the correct pronoun when referring to a Wälzer (tome).
By contrast, if entities are used, the English would be
As noted in the &LIFT;
, Chapter 3…
The translation of this would probably run thus:
Wie in &LIFT;
, Kapitel 3, erwähnt…
And the presentation would be thus:
Wie in Liberty Installation and Formatting Tome, Kapitel 3, erwähnt…
This, of course, leaves the title in English, including words like Tome and Formatting that are unlikely to be understood. Also, the translator is forced to use the pronoun ‘in’, a more general construction that comes close to Denglisch or Angleutsch. Many German speakers consider this approach incorrect and almost all consider it inelegant.
Equivalent problems emerge with a fragment such as this:
However, a careful reading of the Liberty Installation and Formatting Tome afterword, shows that…
With no text hidden behind an entity, a German translation of this might be:
Jedoch ergibt ein sorgfältiges Lesen des Nachworts für den Wälzer für die Installation und Formatierung von Liberty, dass…
If an entity was used to save the writer time, the translator has to deal with this:
However, a careful reading of the &LIFT;
afterword, shows that…
And the translation would be subtly but importantly different:
Jedoch ergibt ein sorgfältiges Lesen des Nachworts für &LIFT;
, dass…
When presented to a reader, this would appear as follows:
Jedoch ergibt ein sorgfältiges Lesen des Nachworts für Liberty Installation and Formatting Tome, dass…
Again, note the missing pronoun, ‘den’. This is inelegant but necessary since the translator can otherwise only guess which pronoun (der, die or das) to use, which would inevitably lead to error.
Now multiply such problems by the 22 languages Publican currently supports. Using entities for anything other than the few non-translated strings currently supported is arguably a conscious effort to inhibit and reduce the quality of translations.
3.3.8. Revision_History.xml
The make
searches for the first XML file in the $(XML_LANG) directory containing a revhistory tag. Publican then uses that file to build the RPM revision history.
Important
All dates must be in the correct RPM format, other formats will break the spec file creation.
Mon Aug 4 2008
In some cases you may need to maintain multiple versions of a book; for example, a HOWTO guide for product FOO can have an upstream version and an enterprise version, with very subtle differences between them.
Publican makes it easy to manage differences between multiple versions of a book by allowing you to simply use one source for all versions. Conditional tagging allows you to make sure that version-specific content only appears in the correct version; i.e. "conditionalizing content".
To conditionalize content in a book, use the tag attribute condition
. For example, let's say the book How To Use Product Foo has an "upstream", "enterprise", and "beta" version:
<para condition="upstream">
This paragraph will only appear in the upstream version of How To Use Product Foo.
</para>
<para condition="enterprise">
This paragraph will only appear in the enterprise version of How To Use Product Foo.
</para>
<para condition="beta">
This paragraph will only appear in the beta version of How To Use Product Foo.
</para>
<para condition="beta,enterprise">
This paragraph will only appear in the beta and enterprise versions of How To Use Product Foo.
</para>
To build a specific version (thereby capturing all content conditionalized for that version), use make
parameter CONDITION="version
" format
. Using the same example for the book How To Use Product Foo, you can build the "upstream" version of the book in pdf using:
make CONDITION="upstream" pdf-en-US
This will capture all tags that use condition="upstream"
and build How To Use Product Foo in PDF format.
Note
You can conditionalize content as per the BRAND
setting. To do so, add the following line to Makefile
:
CONDITION=$(BRAND)
In this manner, make CONDITION="brand1" pdf-en-US
will build the book in PDF and capture all tags that use the condition="brand1"
attribute.
Further, if an <xref>
points to content that is not going to be included in the build due to conditional tagging, the build will fail. For example, make CONDITION="upstream" pdf-en-US
will fail if the book has the tag <xref linkend="betasection"
pointing to <section id="betasection" CONDITION="beta">
.
3.7. Pre-release software and draft documentation
Completed documentation for pre-release software is not the same thing as draft documentation.
Drafts are unfinished versions of a book or article, and their unfinished state is unrelated to the status of the software they document.
In both circumstances, however, it is important to make the status of the software, documentation or both clear to users, developers, readers and reviewers.
3.7.1. Denoting pre-release software
Documentation for pre-release software, especially pre-release software being distributed to testers, customers and partners, should carry a clear mark denoting the beta-status of the software.
To create that mark do the following:
Add the software's pre-release version number, or equivalent state information, to the subtitle in your Book_Info.xml
file. Place this additional text in <remark>
tags. For example:
<subtitle>Using Red Hat Enterprise Warp Drive<remark> Version 1.1, Beta 2</remark></subtitle>
add SHOW_REMARKS
to the Makefile
and set it to '1':
SHOW_REMARKS = 1
When your book is built with this text and setting, the software's status is displayed in clear and unmistakable fashion. PDF builds display the remark on their cover and title pages. HTML builds (both html and html-single) display the remark near the beginning of index.html
Because this approach makes no changes to the information in Book_Info.xml
used to generate RPMs, it also ensures there is no ambiguity in the RPM subsystem's operation.
Important
It is the writer's responsibility to remove the <remark>
tag and its contents and remove or turn off SHOW_REMARKS
when documentation is updated for use with the release version of the software.
3.7.2. Denoting draft documentation
Unfinished documentation made available to others for review should be labeled clearly as such.
By default, your root node is the <book>
tag in your [book_name]
.xml
file.
If you are working on an article or set, the root node is the <article>
or <set>
tag in [book_name]
.xml
.
Adding the status="draft"
attribute causes each page of the document to show the draft watermark. This is by design.
Even if you change only a portion of a work before sending it out for review, marking every page as draft will encourage reviewers to report errors or typos they spot in passing. It will also ensure non-reviewers who encounter the work do not mistake a draft for a finished version.
3.7.3. Denoting draft documentation of pre-release software
To denote unfinished documentation of pre-release software properly simply do both previously noted procedures.