Skip to content

Commit a951ece

Browse files
committed
Merge branch 'release/v0.7.4'
2 parents 5ca96df + 2c41475 commit a951ece

423 files changed

Lines changed: 22428 additions & 7721 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
## Problem Description
8+
A clear and concise description of what the bug is.
9+
10+
## To Reproduce
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
## Expected Behavior
18+
A clear and concise description of what you expected to happen.
19+
20+
21+
## Additional context
22+
Add any other context about the problem here like OS, version, etc.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/issue_template.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ syntax: glob
22
# Temporary files used by the oXygen editor
33
*.~
44
*~
5+
*.bak
56

67
# Temporary directories and files by Python
78
__pycache__
89
*.pyc
910
*.pyo
11+
.tmp/
1012

1113

1214
# Temporary files used by the vim editor.

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ before_install:
1616
install:
1717
- sudo apt-get update -q
1818
- sudo apt-get install xsltproc
19-
- sudo apt-get install libsaxon-java libxml-commons-resolver1.1-java libsaxon-java libxerces2-java
19+
- sudo apt-get install libsaxon-java libxml-commons-resolver1.1-java libsaxon-java libxerces2-java fop
2020
- sudo apt-get install trang jing
2121
- sudo apt-get install python3 python3-lxml
2222

2323
script:
24-
- ./bin/buildbook.py -v --archive
24+
- ./bin/buildbook.py -v html --archive
25+
- ./bin/buildbook.py -v pdf && mv -vi build/fo/*.pdf .
2526

2627
before_deploy:
2728
- git config --local user.name "Travis CI"
@@ -34,6 +35,7 @@ deploy:
3435
file:
3536
- DBCookBook-$VERSION-html.tar.bz2
3637
- DBCookBook-$VERSION-html.zip
38+
- DBCookBook-$VERSION.pdf
3739
skip_cleanup: true
3840
on:
3941
branch: master

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributing to this Book
2+
3+
See http://doccookbook.sf.net/html/en/dbc.preface.contrib.html for more details.

Changelog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
-------------------------------------------------------------------
2+
Mon May 14 08:40:00 UTC 2018 - tom_schr@web.de
3+
4+
Version 0.7.4 Small fixes here and there:
5+
6+
* Update issue template (issue #31)
7+
* Implement subcommands for pdf and html for building the books (commit
8+
88ef68a)
9+
* Use dbtimestamp PI in pubdate (commit 2208bd4)
10+
* Corrected old link from code.google.com (issue #26)
11+
* Update to DocBook 5.1 (commit 6d2c8e8b)
12+
* Update DocBook XSLT2 stylesheet to v2.3.2 (commit c5e95165)
13+
114
-------------------------------------------------------------------
215
Sat Mar 10 23:25:00 UTC 2018 - tom_schr@web.de
316

DocBook-Cookbook.xpr

Lines changed: 94 additions & 134 deletions
Large diffs are not rendered by default.

bin/buildbook.py

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,8 @@
44
import sys
55
import os
66

7-
from dbcookbook.config import config, __version__
8-
from dbcookbook import internaltest
9-
from dbcookbook.cli import parsecommandline
10-
from dbcookbook.log import logger, trace, createlogger
11-
from dbcookbook.env import initenv
12-
from dbcookbook.formats import html
13-
from dbcookbook.categories import resolvecategories
14-
from dbcookbook.zip import createzip
15-
16-
_abspath=os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))+"/"
17-
18-
19-
def main():
20-
parserobj=parsecommandline()
21-
args=parserobj[1]
22-
createlogger(args.verbose)
23-
24-
logger.debug("CLI arguments: {args}".format(args=args))
25-
logger.debug("Found these sections in INI: {sects}".format(sects=config.sections()))
26-
27-
# Set the absolute path, so we always resolve correctly:
28-
config.set('Common', 'abspath', _abspath)
29-
30-
logger.debug("""Environment:
31-
absolute path={path}
32-
xhtmldir={xhtmldir}
33-
fodir={fodir}
34-
""".format(path=_abspath, **dict(config["XSLT1"].items()) ))
35-
36-
initenv(*parserobj)
37-
resolvecategories(*parserobj)
38-
html(*parserobj)
39-
createzip(*parserobj)
40-
41-
return parserobj
7+
from dbcookbook.log import logger
8+
from dbcookbook.main import main
429

4310

4411
def __test():
@@ -48,25 +15,33 @@ def __test():
4815

4916
if __name__=="__main__":
5017
from configparser import InterpolationMissingOptionError
51-
from lxml.etree import XSLTApplyError
18+
from lxml.etree import XSLTApplyError, XSLTParseError
19+
from subprocess import CalledProcessError
5220
line="-"*10
5321

5422
try:
5523
logger.debug("{line} START {line}".format(**locals()))
56-
obj = main()
24+
result = main()
5725

5826
except (InterpolationMissingOptionError,
59-
NameError,
60-
XSLTApplyError,
61-
FileNotFoundError
27+
# NameError,
28+
XSLTApplyError,
29+
XSLTParseError,
30+
FileNotFoundError,
31+
CalledProcessError
6232
) as error:
63-
logger.critical("{classname}: {error}".format(classname=error.__class__.__name__, error=error))
33+
logger.critical("{cls}: {error}".format(cls=error.__class__.__name__,
34+
error=error))
6435
sys.exit(10)
6536

66-
if obj[1].test:
67-
internaltest()
37+
#if obj[1].test:
38+
# from dbcookbook import internaltest
39+
# internaltest()
6840

6941
logger.info("Success!")
42+
# logger.info("Find the result at: ")
7043
logger.debug("{line} END {line}".format(**locals()))
7144

72-
# EOF
45+
sys.exit(result)
46+
47+
# EOF

bin/dbcookbook/cli.py

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# -*- coding: UTF-8 -*-
22

3+
from dbcookbook.categories import resolvecategories
4+
from dbcookbook.env import initenv
5+
from dbcookbook.formats import html, fo
6+
from dbcookbook.log import logger
7+
from dbcookbook.zip import createzip
8+
9+
10+
def func_html(parserobj, args):
11+
logger.debug("-- Create HTML with %s --" % args)
12+
initenv(parserobj, args)
13+
resolvecategories(parserobj, args)
14+
result = html(parserobj, args)
15+
if args.archive:
16+
result = createzip(parserobj, args)
17+
else:
18+
logger.info("Skipping compressed archive creation")
19+
return result
20+
21+
22+
def func_pdf(parserobj, args):
23+
logger.debug("-- Create PDF with %s --", args)
24+
initenv(parserobj, args)
25+
resolvecategories(parserobj, args)
26+
return fo(parserobj, args)
27+
328

429
def parsecommandline():
530
"""Parses commandline and returns parser and parsed arguments
@@ -9,9 +34,15 @@ def parsecommandline():
934
import argparse
1035
from .config import __version__, __author__, LOGFILE, MAINFILE
1136

37+
mainfile = dict(help="Use main XML file (default: %(default)r)",
38+
default=MAINFILE,
39+
nargs='?',
40+
)
1241
parser = argparse.ArgumentParser(
1342
description='Transforms an DocBook XML file into a target format',
1443
)
44+
# Subparsers
45+
sp = parser.add_subparsers(dest='subcmd', help='sub-command help')
1546

1647
parser.add_argument('--version',
1748
action='version',
@@ -60,27 +91,51 @@ def parsecommandline():
6091
type=int,
6192
default=1,
6293
)
63-
parser.add_argument('-A', '--archive',
64-
help="Create compressed files of the HTML build (default: %(default)s)",
65-
action='store_true',
66-
default=False,
67-
)
68-
parser.add_argument('mainfile',
69-
help="Use main XML file (default: %(default)s)",
70-
default=MAINFILE,
71-
nargs='?',
72-
)
94+
7395
# Should go away as soon as the script is stable
7496
parser.add_argument('--test',
7597
help="Just for testing",
7698
action='store_true',
7799
default=False,
78100
)
79-
101+
102+
# HTML Subparser
103+
htmlsub = sp.add_parser('html',
104+
help='Generate HTML')
105+
# sp.set_defaults(subcommand=None)
106+
htmlsub.set_defaults(func=func_html)
107+
htmlsub.add_argument('-A', '--archive',
108+
help=("Create compressed files of the HTML build "
109+
"(default: %(default)s)"),
110+
action='store_true',
111+
default=False,
112+
)
113+
htmlsub.add_argument('mainfile', **mainfile)
114+
115+
# FO Subparser
116+
fosub = sp.add_parser('pdf',
117+
help='Generate PDF from FO')
118+
fosub.set_defaults(func=func_pdf)
119+
fosub.add_argument('-f', '--formatter',
120+
choices=('fop', 'xep'), # axf
121+
default='fop',
122+
help='Format the FO with formatter (default %(default)r)',
123+
)
124+
fosub.add_argument('-o', '--output',
125+
# required=False,
126+
help="Save result PDF in OUTPUT"
127+
)
128+
fosub.add_argument('--opts',
129+
help=("Pass special options to formatter; "
130+
"keep in mind to quote it correctly")
131+
)
132+
fosub.add_argument('mainfile', **mainfile)
133+
134+
80135
args=parser.parse_args()
81-
136+
82137
if args.jobs < 0:
83138
parser.error("argument -j/--job: negative int value: {}. "
84139
"Job values have to be positive.".format(args.jobs))
85-
140+
86141
return parser, args

0 commit comments

Comments
 (0)