Initial commit

Signed-off-by: default avatarHéctor Orón Martínez <hector.oron@collabora.com>
parents
This diff is collapsed.
PACKAGE = apertis-bld-workshop
#REMOTE_PREFIX = https://designs.apertis.org/private
REMOTE_PREFIX =
#PDF_OPTIONS ?= --line-numbers
HOTDOC ?= hotdoc
prefix ?= /usr
datadir ?= ${prefix}/share
devhelpdir ?= ${datadir}/devhelp/books
docdir ?= ${datadir}/doc/${PACKAGE}
htmldir ?= ${docdir}
# emulate Automake well enough for hotdoc.mk
AM_V_GEN ?=
AMTAR ?= tar
mkinstalldirs ?= install -d
srcdir = $(CURDIR)
top_srcdir = $(CURDIR)
builddir = $(CURDIR)
top_builddir = $(CURDIR)
HOTDOC_PROJECTS = apertis-bld-workshop
apertis_bld_workshop_HOTDOC_FLAGS = \
--conf-file hotdoc.json \
$(NULL)
all:
install:
clean:
.PHONY: all install clean
-include $(shell $(HOTDOC) --makefile-path)
HTML_TO_PDF = ./hotdoc-html-2-pdf
PDF_FILES = $(sort $(patsubst docs/%.md,build/pdf/%.pdf,$(wildcard docs/*.md)))
build/pdf/%.pdf: $(call HOTDOC_TARGET,apertis-bld-workshop) $(HTML_TO_PDF)
$(HTML_TO_PDF) $(patsubst build/pdf/%.pdf,build/html/%.html,$@) $@ --remote-prefix "${REMOTE_PREFIX}" ${PDF_OPTIONS}
pdf: $(PDF_FILES)
clean-pdf:
rm -rf build/pdf
clean: clean-pdf
GITIGNOREFILES += \
media/\*.svg.pdf \
$(NULL)
-include git.mk
# Introduction
This repository contains workshop documents written by Collabora
for the Bosch Linux Days 2018 on the topic of Apertis platform.
# Licensing
This workshop is licensed under CC BY-SA 4.0 International. See COPYING
for more details.
# Build documentation
Documentation builds using [hotdoc](https://github.com/hotdoc/hotdoc) tool, to be able to get proper
environment, a docker image exists to build documentation as follows:
```
RELEASE_VERSION="18.09" ;
docker run --device /dev/kvm \
-w /documentation \
-u $(id -u) \
--group-add=$(getent group kvm | cut -d : -f 3) \
-i -v $(pwd):/documentation \
-t docker-registry.apertis.org/apertis/apertis-${RELEASE_VERSION}-documentation-builder \
make
```
If you want PDF version use `make pdf` instead.
This diff is collapsed.
# Customizing Apertis
This diff is collapsed.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright © 2016 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
# Copyright © 2016 Collabora Ltd
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from lxml import etree
import lxml.html
import io
import os
import sys
import urlparse
import argparse
import tempfile
import subprocess
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def require_program(program):
if which(program) is None:
print "Checking for %s: no" % program
print "Please install %s" % program
sys.exit(1)
# Hotdoc outputs relative inter-document links.
# As these won't work with a pdf output, redirect these
# instead to the official web portal.
def update_local_links(elem, prefix):
links = elem.xpath('.//a')
for link in links:
href = link.attrib.get('href')
if href is None:
continue
url_components = urlparse.urlparse(href)
if url_components.scheme or url_components.netloc:
continue # Not a local link
if not url_components.path:
continue # Local link, but doesn't need updating (eg #my-anchor)
link.attrib['href'] = '%s/%s' % (prefix, href)
def convert_svg_images(elem):
imgs = elem.xpath('.//img')
for img in imgs:
src = img.attrib.get('src')
if src is None:
continue
url_components = urlparse.urlparse(src)
if url_components.scheme or url_components.netloc:
continue # Not a local url
if not url_components.path:
continue # Local url, but doesn't need updating (eg #my-anchor)
if not url_components.path.endswith('.svg'):
continue
converted = os.path.abspath(src) + '.pdf'
cmd = ['/usr/bin/rsvg-convert', src, '-f', 'pdf', '-o', converted]
subprocess.check_call(cmd)
img.attrib['src'] = converted
def transform(args):
with io.open(args.input, 'r', encoding='utf-8') as _:
contents = _.read()
root = etree.HTML(contents)
output = []
head = root.find(".//head")
body = root.find(".//*[@id='page-description']")
if head is None or body is None:
print "Unexpected html"
sys.exit(1)
if args.remote_prefix:
update_local_links(body, args.remote_prefix)
convert_svg_images(body)
output.append('<!DOCTYPE html>')
output.append('<html lang="en">')
output.append(lxml.html.tostring(head, include_meta_content_type=True))
output.append('<body>')
output.append(lxml.html.tostring(body))
output.append('</body>')
output.append('</html>')
return output
def write(args, output):
program_dir = os.path.dirname(os.path.realpath(__file__))
latex_dir = os.path.join(program_dir, "latex")
# We need to stay in the same directory as the original html file
# as pandoc doesn't know about assets paths otherwise
inpath = os.path.dirname(args.input)
os.chdir(inpath)
tmp_html, tmp_path = tempfile.mkstemp(prefix=os.path.join(inpath, ''),
suffix='.html')
os.write(tmp_html, u'\n'.join(output))
folder = os.path.dirname(args.output)
if not os.path.exists(folder):
os.makedirs(folder)
cmd = ['/usr/bin/pandoc', tmp_path, '-V documentclass=article',
'--variable', 'links-as-notes=true',
'--latex-engine=xelatex', '--toc', '-o', args.output,
'--include-in-header='+os.path.join(latex_dir, 'collabora_logo.latex')]
if args.line_numbers:
cmd += ['--include-in-header='+os.path.join(latex_dir, 'linenumbers.latex')]
status = subprocess.call(cmd)
os.close(tmp_html)
return status
DESCRIPTION=\
'''
This program transforms html as output by hotdoc to
pdf, performing a few optimisations for that target format.
'''
if __name__=='__main__':
# Basic sanity check.
# If xelatex or relevant texlive packages are missing, pandoc will tell
# the user.
require_program('pandoc')
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument('input')
parser.add_argument('output')
parser.add_argument('--remote-prefix',
help='The url of the official web portal, if provided '
'local links will be prefixed with it.')
parser.add_argument('--line-numbers',
action="store_true",
help='Add line numbers to the output document.')
args = parser.parse_args()
# We want to work with absolute paths
args.input = os.path.abspath(args.input)
args.output = os.path.abspath(args.output)
output = transform(args)
status = write(args, output)
sys.exit(status)
{
"project_name": "apertis-bld-workshop",
"project_version": "1",
"index": "docs/index.md",
"output": "build",
"sitemap": "sitemap.txt",
"extra_assets": ["media"],
"html_number_headings": true,
"syntax_highlighting_activate": true,
"default-license": "CC-BY-SAv4.0",
"default-copyright-holders": [
{ "name": "Collabora", "years": [2018] }
],
"authors_hold_copyright": false
}
\usepackage{graphicx}
\makeatletter
\def\maketitle{%
\null
\thispagestyle{empty}%
\centerline{\includegraphics[width=20em]{../../media/apertis_logo_blue.png}}
\vfill
\centerline{{\LARGE \@title}}\par%
\vfill
\null
\cleardoublepage
}
\makeatother
\usepackage{graphicx}
\makeatletter
\def\maketitle{%
\null
\thispagestyle{empty}%
\centerline{\includegraphics[width=20em]{../../media/collabora_logo.png}}
\vfill
\centerline{{\LARGE \@title}}\par%
\vfill
\null
\cleardoublepage
}
\makeatother
\usepackage{lineno}
\linenumbers
index.md
customizing-apps-and-images-with-apertis-sdk.md
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment