forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts for generating specification PDF
- Loading branch information
Showing
9 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@ECHO OFF | ||
SETLOCAL EnableDelayedExpansion | ||
|
||
REM NOTES: | ||
REM "toc" -> treated just like another page, its location can be changed | ||
REM "--window-status loaded" -> when window.status is set to "loaded", wkhtmltopdf knows js is loaded | ||
|
||
SET THIS_SCRIPT_DIR=%~dp0 | ||
SET ROOT_DIR=%THIS_SCRIPT_DIR%.. | ||
SET SPEC_SRC_DIR=%ROOT_DIR%\spec | ||
SET SPEC_BUILD_DIR=%ROOT_DIR%\build\spec | ||
|
||
SET WKHTML_OPTS=--print-media-type --window-status loaded --footer-center [page] --javascript-delay 1000 | ||
SET WKHTML_TOC=toc --xsl-style-sheet %SPEC_SRC_DIR%\spec-toc.xslt | ||
|
||
SET HTML_FILES= | ||
FOR /F "tokens=*" %%a IN ('dir %SPEC_BUILD_DIR%\*.html /B /O:N ^| findstr /v /i "index.*"') DO ( | ||
SET HTML_FILES=!HTML_FILES! %SPEC_BUILD_DIR%\%%a | ||
) | ||
ECHO Making Spec.pdf with HTML files: | ||
ECHO %SPEC_BUILD_DIR%\index.html %HTML_FILES% | ||
|
||
echo wkhtmltopdf %WKHTML_OPTS% %SPEC_BUILD_DIR%\index.html %WKHTML_TOC% %HTML_FILES% %SPEC_BUILD_DIR%\Spec.pdf | ||
|
||
REM first goes index.html, then TOC, then rest | ||
wkhtmltopdf %WKHTML_OPTS% %SPEC_BUILD_DIR%\index.html %WKHTML_TOC% %HTML_FILES% %SPEC_BUILD_DIR%\Spec.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# NOTES: | ||
# "toc" -> treated just like another page, its location can be changed | ||
# "--window-status loaded" -> when window.status is set to "loaded", wkhtmltopdf knows js is loaded | ||
|
||
ROOT_DIR=.. | ||
SPEC_SRC_DIR=$ROOT_DIR/spec | ||
SPEC_BUILD_DIR=$ROOT_DIR/build/spec | ||
|
||
WKHTML_OPTS="--print-media-type --window-status loaded --footer-center [page]" | ||
WKHTML_TOC="toc --xsl-style-sheet $SPEC_SRC_DIR/spec-toc.xslt" | ||
|
||
# exclude index.html, prepend SPEC_BUILD_DIR path | ||
HTML_FILES=$(ls $SPEC_BUILD_DIR -I 'index.html' | grep '\.html$' | while read line; do echo "$SPEC_BUILD_DIR/$line"; done) | ||
echo "Making Spec.pdf with HTML files: " | ||
echo $SPEC_BUILD_DIR/index.html $HTML_FILES | ||
# first goes index.html, then TOC, then rest | ||
wkhtmltopdf $WKHTML_OPTS $SPEC_BUILD_DIR/index.html $WKHTML_TOC $HTML_FILES $SPEC_BUILD_DIR/Spec.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
<div class="hidden-print"> | ||
|
||
<h1>Table of Contents</h1> | ||
|
||
<ol> | ||
{% assign sorted_pages = site.pages | sort:"name" %} | ||
{% for post in sorted_pages %} | ||
<!-- exclude this page from the toc, not sure how to check | ||
whether there is no chapter variable in the page --> | ||
{% if post.chapter >= 0 %} | ||
<li> | ||
<a href="{{site.baseurl}}{{ post.url }}"> {{ post.title }}</a> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
</ol> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
</head> | ||
|
||
<body> | ||
<header> | ||
<header class="hidden-print"> | ||
<nav id="chapters"> | ||
<a href="{{site.baseurl}}/" title="Table of Contents">Scala {{ site.thisScalaVersion }}</a> | ||
<a id="github" href="https://github.com/scala/scala/tree/2.13.x/spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a> | ||
|
@@ -42,7 +42,7 @@ | |
{% endfor %} | ||
</nav> | ||
</header> | ||
<aside class="left"><nav id="toc"></nav></aside> | ||
<aside class="left hidden-print"><nav id="toc"></nav></aside> | ||
|
||
<main id="content"> | ||
{% include version-notice.yml %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="2.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:outline="http://wkhtmltopdf.org/outline" | ||
xmlns="http://www.w3.org/1999/xhtml"> | ||
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" | ||
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" | ||
indent="yes" /> | ||
<xsl:template match="outline:outline"> | ||
<html> | ||
<head> | ||
<title>Table of Contents</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<link rel="stylesheet" type="text/css"> | ||
<xsl:attribute name="href">./public/stylesheets/fonts.css</xsl:attribute> | ||
</link> | ||
<style> | ||
h1 { | ||
text-align: center; | ||
font-size: 20px; | ||
font-family: Heuristica,Georgia,serif; | ||
} | ||
div {border-bottom: 1px dashed rgb(200,200,200);} | ||
span {float: right;} | ||
li {list-style: none;} | ||
ul { | ||
font-size: 20px; | ||
font-family: Heuristica,Georgia,serif; | ||
} | ||
ul ul {font-size: 80%; } | ||
ul {padding-left: 0em;} | ||
ul ul {padding-left: 1em;} | ||
a {text-decoration:none; color: black;} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Table of Contents</h1> | ||
<ul><xsl:apply-templates select="outline:item/outline:item"/></ul> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
<xsl:template match="outline:item"> | ||
<li> | ||
<xsl:if test="@title!=''"> | ||
<div> | ||
<a> | ||
<xsl:if test="@link"> | ||
<xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute> | ||
</xsl:if> | ||
<xsl:if test="@backLink"> | ||
<xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute> | ||
</xsl:if> | ||
<xsl:value-of select="@title" /> | ||
</a> | ||
<span> <xsl:value-of select="@page" /> </span> | ||
</div> | ||
</xsl:if> | ||
<ul> | ||
<xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment> | ||
<xsl:apply-templates select="outline:item"/> | ||
</ul> | ||
</li> | ||
</xsl:template> | ||
</xsl:stylesheet> |