From 35d24eff6071cef502fe5e58a49c70ec055afd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Wed, 10 Oct 2018 09:36:10 +0200 Subject: [PATCH 01/20] Move Bazel workspace to the root directory. --- README.md | 2 ++ jflex/examples/WORKSPACE => WORKSPACE | 5 +---- {jflex/examples/third_party => third_party}/BUILD | 0 {jflex/examples/third_party => third_party}/README.md | 0 .../third_party => third_party}/com/google/guava/BUILD | 0 .../third_party => third_party}/com/google/truth/BUILD | 0 .../examples/third_party => third_party}/de/jflex/.gitignore | 0 {jflex/examples/third_party => third_party}/de/jflex/BUILD | 0 .../examples/third_party => third_party}/de/jflex/README.md | 0 .../third_party => third_party}/de/jflex/build_rules.bzl | 0 .../third_party => third_party}/generate_workspace.bzl | 0 {jflex/examples/third_party => third_party}/junit/BUILD | 0 12 files changed, 3 insertions(+), 4 deletions(-) rename jflex/examples/WORKSPACE => WORKSPACE (63%) rename {jflex/examples/third_party => third_party}/BUILD (100%) rename {jflex/examples/third_party => third_party}/README.md (100%) rename {jflex/examples/third_party => third_party}/com/google/guava/BUILD (100%) rename {jflex/examples/third_party => third_party}/com/google/truth/BUILD (100%) rename {jflex/examples/third_party => third_party}/de/jflex/.gitignore (100%) rename {jflex/examples/third_party => third_party}/de/jflex/BUILD (100%) rename {jflex/examples/third_party => third_party}/de/jflex/README.md (100%) rename {jflex/examples/third_party => third_party}/de/jflex/build_rules.bzl (100%) rename {jflex/examples/third_party => third_party}/generate_workspace.bzl (100%) rename {jflex/examples/third_party => third_party}/junit/BUILD (100%) diff --git a/README.md b/README.md index ac82b6992..6ef7cbd96 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ The top level directory of the JFLex git repository contains: * **jflex-maven-plugin** the JFlex maven plugin, that helps to integrate JFlex in your project * **jflex-unicode-plugin** the JFlex unicode maven plugin, used for compiling JFlex * **testsuite** the regression test suite for JFlex, + * **third_party** third-party librairies used by examples of the [Bazel build system][bazel] ## Usage @@ -109,3 +110,4 @@ See the [Contributing][contrib] page for instructions. [example-simple]: https://github.com/jflex-de/jflex/tree/master/jflex/examples/simple [examples]: https://github.com/jflex-de/jflex/tree/master/jflex/examples/ [contrib]: https://github.com/jflex-de/jflex/wiki/Contributing +[bazel]: http://bazel.build/ diff --git a/jflex/examples/WORKSPACE b/WORKSPACE similarity index 63% rename from jflex/examples/WORKSPACE rename to WORKSPACE index 07566ad55..4a5cd2389 100644 --- a/jflex/examples/WORKSPACE +++ b/WORKSPACE @@ -1,10 +1,7 @@ # Workspace file for the Bazel build system # https://bazel.build/ -# JFlex doesn't use Bazel itself, but some examples do. -# This WORKSPACE is only to illustrate usage of Bazel on the examples. -# In a real usage, the WORKSPACE file is at the root of the workspace. -# https://docs.bazel.build/versions/master/build-ref.html#workspace +# JFlex itself is not built with Bazel, but some examples and the documentation do. # TODO(#390) Add maven 1.7.0 when cup_runtime is published # de.jflex:jflex-maven-plugin:maven-plugin:1.6.1 diff --git a/jflex/examples/third_party/BUILD b/third_party/BUILD similarity index 100% rename from jflex/examples/third_party/BUILD rename to third_party/BUILD diff --git a/jflex/examples/third_party/README.md b/third_party/README.md similarity index 100% rename from jflex/examples/third_party/README.md rename to third_party/README.md diff --git a/jflex/examples/third_party/com/google/guava/BUILD b/third_party/com/google/guava/BUILD similarity index 100% rename from jflex/examples/third_party/com/google/guava/BUILD rename to third_party/com/google/guava/BUILD diff --git a/jflex/examples/third_party/com/google/truth/BUILD b/third_party/com/google/truth/BUILD similarity index 100% rename from jflex/examples/third_party/com/google/truth/BUILD rename to third_party/com/google/truth/BUILD diff --git a/jflex/examples/third_party/de/jflex/.gitignore b/third_party/de/jflex/.gitignore similarity index 100% rename from jflex/examples/third_party/de/jflex/.gitignore rename to third_party/de/jflex/.gitignore diff --git a/jflex/examples/third_party/de/jflex/BUILD b/third_party/de/jflex/BUILD similarity index 100% rename from jflex/examples/third_party/de/jflex/BUILD rename to third_party/de/jflex/BUILD diff --git a/jflex/examples/third_party/de/jflex/README.md b/third_party/de/jflex/README.md similarity index 100% rename from jflex/examples/third_party/de/jflex/README.md rename to third_party/de/jflex/README.md diff --git a/jflex/examples/third_party/de/jflex/build_rules.bzl b/third_party/de/jflex/build_rules.bzl similarity index 100% rename from jflex/examples/third_party/de/jflex/build_rules.bzl rename to third_party/de/jflex/build_rules.bzl diff --git a/jflex/examples/third_party/generate_workspace.bzl b/third_party/generate_workspace.bzl similarity index 100% rename from jflex/examples/third_party/generate_workspace.bzl rename to third_party/generate_workspace.bzl diff --git a/jflex/examples/third_party/junit/BUILD b/third_party/junit/BUILD similarity index 100% rename from jflex/examples/third_party/junit/BUILD rename to third_party/junit/BUILD From 3f6c39b641716626aa635a2ff253e85aaee2eb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Wed, 10 Oct 2018 10:00:40 +0200 Subject: [PATCH 02/20] Build the concatenated manual.mdx with Bazel --- WORKSPACE | 11 +++++++++++ docs/BUILD | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 docs/BUILD diff --git a/WORKSPACE b/WORKSPACE index 4a5cd2389..e66e898bb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,3 +15,14 @@ maven_jar( load("//third_party:generate_workspace.bzl", "generated_maven_jars") generated_maven_jars() + +http_archive( + name = "bazel_pandoc", + strip_prefix = "bazel-pandoc-0.1", + url = "https://github.com/ProdriveTechnologies/bazel-pandoc/archive/v0.1.tar.gz", +) + + +load("@bazel_pandoc//:repositories.bzl", "pandoc_repositories") + +pandoc_repositories() diff --git a/docs/BUILD b/docs/BUILD new file mode 100644 index 000000000..edbed882f --- /dev/null +++ b/docs/BUILD @@ -0,0 +1,34 @@ +# Build the user manual + +load("@bazel_pandoc//:pandoc.bzl", "pandoc") + +VERSION="1.7.1-SNAPSHOT" +RELEASE_DATE="21 September 2018" +UNICODE_VER="9.0" + +pandoc( + name = "html", + src = "manual.mdx", + from_format = "markdown", + to_format = "html", +) + +genrule( + name = "concatenated_manual", + srcs=[ + "md/head.md", + "md/intro.md", + "md/installing.md", + "md/maven-plugin.md", + "md/ant-task.md", + "md/example.md", + "md/lex-specs.md", + "md/encodings.md", + "md/performance.md", + "md/porting-and-parsers.md", + "md/end.md", + ], + cmd = "cat $(SRCS) > $@", + outs = ["concatenated_manual.mdx"], +) + From e87b2f365aa7b54d85781eff3b29c9cb701678c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Wed, 10 Oct 2018 10:25:37 +0200 Subject: [PATCH 03/20] Do variable substirtution in manual.mdx --- docs/BUILD | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index edbed882f..6373b7b23 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -2,9 +2,11 @@ load("@bazel_pandoc//:pandoc.bzl", "pandoc") -VERSION="1.7.1-SNAPSHOT" -RELEASE_DATE="21 September 2018" -UNICODE_VER="9.0" +VERSION = "1.7.1-SNAPSHOT" + +RELEASE_DATE = "21 September 2018" + +UNICODE_VER = "9.0" pandoc( name = "html", @@ -13,22 +15,32 @@ pandoc( to_format = "html", ) +genrule( + name = "manual_mdx", + srcs = [":concatenated_manual"], + outs = ["manual.mdx"], + cmd = "sed -e 's/\$$VERSION/" + VERSION + "/g'" + + " -e 's/\$${project.version}/" + VERSION + "/g'" + + " -e 's/\$$RELEASE_DATE/" + RELEASE_DATE + "/g'" + + " -e 's/\$$UNICODE_VER/" + UNICODE_VER + "/g'" + + " $< > $@", +) + genrule( name = "concatenated_manual", - srcs=[ - "md/head.md", - "md/intro.md", - "md/installing.md", - "md/maven-plugin.md", - "md/ant-task.md", - "md/example.md", - "md/lex-specs.md", - "md/encodings.md", - "md/performance.md", - "md/porting-and-parsers.md", - "md/end.md", - ], - cmd = "cat $(SRCS) > $@", + srcs = [ + "md/head.md", + "md/intro.md", + "md/installing.md", + "md/maven-plugin.md", + "md/ant-task.md", + "md/example.md", + "md/lex-specs.md", + "md/encodings.md", + "md/performance.md", + "md/porting-and-parsers.md", + "md/end.md", + ], outs = ["concatenated_manual.mdx"], + cmd = "cat $(SRCS) > $@", ) - From 5aec2e46b3ee627c29aed1c753d91008c6bcfe35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Wed, 10 Oct 2018 10:35:07 +0200 Subject: [PATCH 04/20] Build manual.html If pandoc is installed on the system --- docs/BUILD | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 6373b7b23..42a4d4992 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -1,6 +1,7 @@ # Build the user manual -load("@bazel_pandoc//:pandoc.bzl", "pandoc") +# Consider using +# load("@bazel_pandoc//:pandoc.bzl", "pandoc") VERSION = "1.7.1-SNAPSHOT" @@ -8,11 +9,12 @@ RELEASE_DATE = "21 September 2018" UNICODE_VER = "9.0" -pandoc( + +genrule( name = "html", - src = "manual.mdx", - from_format = "markdown", - to_format = "html", + srcs = ["manual.mdx"], + cmd = "pandoc --smart --css manual.css --filter pandoc-citeproc -f markdown $< -o $@", + outs = ["manual.html"], ) genrule( From 6da8d3429518bb39c7891484c607c57a963c1e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 19:27:52 +0200 Subject: [PATCH 05/20] Generate manual.html with pandoc on Bazel using my fork version of bazel_pandoc because the orginal one doesn't allow to sepcifiy the output. --- WORKSPACE | 12 ++++++++++-- docs/BUILD | 15 ++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index e66e898bb..ffe18a526 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,10 +16,18 @@ load("//third_party:generate_workspace.bzl", "generated_maven_jars") generated_maven_jars() +# TODO(regisd) Take upstream when they have accepted my PR to allow specifying output +# https://github.com/ProdriveTechnologies/bazel-pandoc/pull/1 +#http_archive( +# name = "bazel_pandoc", +# strip_prefix = "bazel-pandoc-0.1", +# url = "https://github.com/ProdriveTechnologies/bazel-pandoc/archive/v0.1.tar.gz", +#) http_archive( name = "bazel_pandoc", - strip_prefix = "bazel-pandoc-0.1", - url = "https://github.com/ProdriveTechnologies/bazel-pandoc/archive/v0.1.tar.gz", + strip_prefix = "bazel_pandoc-0.1.1", + url = "https://github.com/regisd/bazel_pandoc/archive/v0.1.1.tar.gz", + sha256 = "0dd9d0d44658d46a96c36caba25f7ce9f119a6883c3219f61b76c11cfdc83c8f", ) diff --git a/docs/BUILD b/docs/BUILD index 42a4d4992..990bbc118 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -1,7 +1,6 @@ # Build the user manual -# Consider using -# load("@bazel_pandoc//:pandoc.bzl", "pandoc") +load("@bazel_pandoc//:pandoc.bzl", "pandoc") VERSION = "1.7.1-SNAPSHOT" @@ -9,14 +8,15 @@ RELEASE_DATE = "21 September 2018" UNICODE_VER = "9.0" - -genrule( +pandoc( name = "html", - srcs = ["manual.mdx"], - cmd = "pandoc --smart --css manual.css --filter pandoc-citeproc -f markdown $< -o $@", - outs = ["manual.html"], + src = ":manual_mdx", + from_format = "markdown", + output = "manual.html", + to_format = "html", ) +# Replaces placeholders by their respective value. genrule( name = "manual_mdx", srcs = [":concatenated_manual"], @@ -28,6 +28,7 @@ genrule( " $< > $@", ) +# Concatenates all pages in a single document. genrule( name = "concatenated_manual", srcs = [ From 67f8d357bda5b91fe91bd69b46c9bd8431db5a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 19:40:28 +0200 Subject: [PATCH 06/20] Try to add the pandoc options. All failed :-/ --- docs/BUILD | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/BUILD b/docs/BUILD index 990bbc118..7ae60eed5 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -14,6 +14,13 @@ pandoc( from_format = "markdown", output = "manual.html", to_format = "html", + # TODO: Add "--css manual.css" when the rule accepts data files + # + # TODO: Add "+smart" when the toolchain supports it + # + # TODO: Add ["--filter", "pandoc-citeproc"] when #2 is fixed + # https://github.com/ProdriveTechnologies/bazel-pandoc/issues/2 + options = [], ) # Replaces placeholders by their respective value. From 4ca8df1e486ee7d09bd675c470476b574898ed8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 19:45:43 +0200 Subject: [PATCH 07/20] Add pandoc target to generate manual.tex --- docs/BUILD | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/BUILD b/docs/BUILD index 7ae60eed5..8748afb27 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -23,6 +23,13 @@ pandoc( options = [], ) +pandoc( + name = "latex", + src = ":manual_mdx", + from_format = "markdown", + to_format = "latex", +) + # Replaces placeholders by their respective value. genrule( name = "manual_mdx", @@ -51,6 +58,6 @@ genrule( "md/porting-and-parsers.md", "md/end.md", ], - outs = ["concatenated_manual.mdx"], + outs = ["concatenated_manual.md"], cmd = "cat $(SRCS) > $@", ) From f97f400612e3bb5061eb040be4a6ee737686ce3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 20:57:37 +0200 Subject: [PATCH 08/20] Split xmanual.tex in two, because I can't make \include{} to work --- docs/manual_end.tex | 8 ++++++ docs/manual_start.tex | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 docs/manual_end.tex create mode 100644 docs/manual_start.tex diff --git a/docs/manual_end.tex b/docs/manual_end.tex new file mode 100644 index 000000000..ab92473bf --- /dev/null +++ b/docs/manual_end.tex @@ -0,0 +1,8 @@ +% Closing the manual, when doc built with bazel + +\newpage + +\bibliographystyle{plain} +\bibliography{manual} + +\end{document} diff --git a/docs/manual_start.tex b/docs/manual_start.tex new file mode 100644 index 000000000..dfc27bc4a --- /dev/null +++ b/docs/manual_start.tex @@ -0,0 +1,63 @@ +% Starting the manual, when doc built with bazel + +\documentclass[11pt]{scrartcl} +\usepackage{a4wide,verbatim,graphicx,upquote,microtype} + +\usepackage{color} +\definecolor{lcol}{rgb}{0,0,0.5} +\usepackage[unicode=true,bookmarks, + colorlinks=true,linkcolor=lcol,citecolor=lcol, + filecolor=lcol,urlcolor=lcol, + pdfauthor={Gerwin Klein, Steve Rowe, Regis Decamps}, + pdftitle={JFlex User's Manual}, + pdfkeywords={Java, scanner, lexer, scanner generator}, + plainpages=false]{hyperref} + + +% pandoc packages +\usepackage{lmodern} +\usepackage{fixltx2e} % provides \textsubscript +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} + +\newcommand{\textcite}[1]{\cite{#1}} +\newcommand{\autocite}[1]{\cite{#1}} + +\renewcommand{\textquotesingle}{'} + +\let\orighyperref\hyperref +\renewcommand{\hyperref}[2][]{\orighyperref[#1]{#2} (\autoref{#1})} + +\let\ttf\ttfamily +\renewcommand{\ttfamily}{\small\ttf} + +\renewcommand{\sectionautorefname}{Section} +\renewcommand{\subsectionautorefname}{Section} +\renewcommand{\subsubsectionautorefname}{Section} +\renewcommand{\Hfootnoteautorefname}{Footnote} + +\setlength{\parindent}{0pt} +\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} + + +\begin{document} + +% can't find file fix.jflex-black.png +%\centerline{\includegraphics[width=0.6\textwidth]{fig/jflex-black.png}} + +\begin{center} +\sffamily +{\Large The Fast Lexical Analyser Generator}\\ +\smallskip\smallskip +Copyright \copyright\ 1998--2018 by \href{http://www.doclsf.de}{Gerwin Klein}, +Steve Rowe, and \href{http://regis.decamps.info/}{R\'egis D\'ecamps}. + +\vspace*{15ex} +{\Huge \sffamily \bfseries JFlex User's Manual}\\ +\bigskip +Version 1.7.1-SNAPSHOT, {\today} +\end{center} + +\newpage +\tableofcontents +\newpage From 81a75d08e4fda6bdc1a9e452cdc185d1866c0662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 20:59:21 +0200 Subject: [PATCH 09/20] Remove image inclusion, because I can't resolve the path in the runtime dir. --- docs/manual_start.tex | 1 + docs/md/head.md | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/manual_start.tex b/docs/manual_start.tex index dfc27bc4a..e592a3dee 100644 --- a/docs/manual_start.tex +++ b/docs/manual_start.tex @@ -42,6 +42,7 @@ \begin{document} +% TODO Find real bath of image % can't find file fix.jflex-black.png %\centerline{\includegraphics[width=0.6\textwidth]{fig/jflex-black.png}} diff --git a/docs/md/head.md b/docs/md/head.md index 1fbc4cb34..c6efc90c9 100644 --- a/docs/md/head.md +++ b/docs/md/head.md @@ -4,7 +4,9 @@ bibliography: manual.bib ---
-![](fig/jflex-black.png) +```TODO +`![](fig/jflex-black.png) +``` The Fast Lexical Analyser Generator From 9320a9f0d01e29c2729731bc7e41ac3fa3944200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 21:00:01 +0200 Subject: [PATCH 10/20] Latest version of pandoc uses \tightlist defined in template https://github.com/jgm/pandoc-templates/blob/master/default.latex --- docs/manual_start.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/manual_start.tex b/docs/manual_start.tex index e592a3dee..895fdc346 100644 --- a/docs/manual_start.tex +++ b/docs/manual_start.tex @@ -39,6 +39,9 @@ \setlength{\parindent}{0pt} \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} +% pandoc now uses \tightlist +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \begin{document} From 98da45dcd58f14ef7e498b5448983b7f9fc9c492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 21:00:30 +0200 Subject: [PATCH 11/20] Build the PDF with Bazel (first pass) --- docs/BUILD | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 8748afb27..9a51af826 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -8,12 +8,12 @@ RELEASE_DATE = "21 September 2018" UNICODE_VER = "9.0" +GENRULE_CONCATENATE = "cat $(SRCS) > $@" + pandoc( name = "html", src = ":manual_mdx", from_format = "markdown", - output = "manual.html", - to_format = "html", # TODO: Add "--css manual.css" when the rule accepts data files # # TODO: Add "+smart" when the toolchain supports it @@ -21,15 +21,41 @@ pandoc( # TODO: Add ["--filter", "pandoc-citeproc"] when #2 is fixed # https://github.com/ProdriveTechnologies/bazel-pandoc/issues/2 options = [], + output = "manual.html", + to_format = "html", ) pandoc( - name = "latex", + name = "latex_content", src = ":manual_mdx", from_format = "markdown", + output = "content.tex", # If changed, then change \include{} in manual.tex to_format = "latex", ) +genrule( + name = "manual_full_tex", + srcs = [ + "manual_start.tex", + ":latex_content", + "manual_end.tex", + ], + outs = ["manual_full.tex"], + cmd = GENRULE_CONCATENATE, +) + +genrule( + name = "pre_pdf", + srcs = [ + ":manual_full_tex", + ], + outs = [ + "manual_full.pdf", + "manual_full.log", + ], + cmd = "pdflatex -output-directory $(@D) $(location :manual_full_tex)", +) + # Replaces placeholders by their respective value. genrule( name = "manual_mdx", @@ -59,5 +85,5 @@ genrule( "md/end.md", ], outs = ["concatenated_manual.md"], - cmd = "cat $(SRCS) > $@", + cmd = GENRULE_CONCATENATE, ) From 8d77e4575761c965e32b574574f1d5f986dbc42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 21:04:07 +0200 Subject: [PATCH 12/20] Output the PDF to bindir --- docs/BUILD | 1 + docs/md/head.md | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 9a51af826..a9f9a099d 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -54,6 +54,7 @@ genrule( "manual_full.log", ], cmd = "pdflatex -output-directory $(@D) $(location :manual_full_tex)", + output_to_bindir = True, ) # Replaces placeholders by their respective value. diff --git a/docs/md/head.md b/docs/md/head.md index c6efc90c9..922e2a43d 100644 --- a/docs/md/head.md +++ b/docs/md/head.md @@ -4,9 +4,7 @@ bibliography: manual.bib ---
-```TODO -`![](fig/jflex-black.png) -``` +TODO: Restore image The Fast Lexical Analyser Generator From ffea6620b7c751a494ca027be530a208120f19aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 21:26:13 +0200 Subject: [PATCH 13/20] pdflatex from bazel is annoying. let's try bazel_latex rules instead! Currently: scrartcl.cls not found --- WORKSPACE | 10 ++++++++++ docs/BUILD | 27 +++++---------------------- docs/{manual_start.tex => manual.tex} | 11 ++++++++++- docs/manual_end.tex | 8 -------- 4 files changed, 25 insertions(+), 31 deletions(-) rename docs/{manual_start.tex => manual.tex} (91%) delete mode 100644 docs/manual_end.tex diff --git a/WORKSPACE b/WORKSPACE index ffe18a526..a6e06df0d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -34,3 +34,13 @@ http_archive( load("@bazel_pandoc//:repositories.bzl", "pandoc_repositories") pandoc_repositories() + +http_archive( + name = "bazel_latex", + strip_prefix = "bazel-latex-0.9", + url = "https://github.com/ProdriveTechnologies/bazel-latex/archive/v0.9.tar.gz", +) + +load("@bazel_latex//:repositories.bzl", "latex_repositories") + +latex_repositories() diff --git a/docs/BUILD b/docs/BUILD index a9f9a099d..f85484baf 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -1,6 +1,7 @@ # Build the user manual load("@bazel_pandoc//:pandoc.bzl", "pandoc") +load("@bazel_latex//:latex.bzl", "latex_document") VERSION = "1.7.1-SNAPSHOT" @@ -33,28 +34,10 @@ pandoc( to_format = "latex", ) -genrule( - name = "manual_full_tex", - srcs = [ - "manual_start.tex", - ":latex_content", - "manual_end.tex", - ], - outs = ["manual_full.tex"], - cmd = GENRULE_CONCATENATE, -) - -genrule( - name = "pre_pdf", - srcs = [ - ":manual_full_tex", - ], - outs = [ - "manual_full.pdf", - "manual_full.log", - ], - cmd = "pdflatex -output-directory $(@D) $(location :manual_full_tex)", - output_to_bindir = True, +latex_document( + name = "pdf", + srcs = ["manual.tex", ":latex_content"], + main = "manual.tex", ) # Replaces placeholders by their respective value. diff --git a/docs/manual_start.tex b/docs/manual.tex similarity index 91% rename from docs/manual_start.tex rename to docs/manual.tex index 895fdc346..a71601e29 100644 --- a/docs/manual_start.tex +++ b/docs/manual.tex @@ -1,4 +1,4 @@ -% Starting the manual, when doc built with bazel +% The Latex template for the manual, when doc built with bazel \documentclass[11pt]{scrartcl} \usepackage{a4wide,verbatim,graphicx,upquote,microtype} @@ -65,3 +65,12 @@ \newpage \tableofcontents \newpage + +\include{manual_content} + +\newpage + +\bibliographystyle{plain} +\bibliography{manual} + +\end{document} diff --git a/docs/manual_end.tex b/docs/manual_end.tex deleted file mode 100644 index ab92473bf..000000000 --- a/docs/manual_end.tex +++ /dev/null @@ -1,8 +0,0 @@ -% Closing the manual, when doc built with bazel - -\newpage - -\bibliographystyle{plain} -\bibliography{manual} - -\end{document} From 93d13a66d551a9daef71ec921b140d62983a2208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 21:31:46 +0200 Subject: [PATCH 14/20] Comment out scrartcl The Bazel rule doesn't know about https://ctan.org/pkg/scrartcl --- docs/manual.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manual.tex b/docs/manual.tex index a71601e29..7f5f74f4d 100644 --- a/docs/manual.tex +++ b/docs/manual.tex @@ -1,6 +1,6 @@ % The Latex template for the manual, when doc built with bazel -\documentclass[11pt]{scrartcl} +\documentclass[11pt] %{scrartcl} \usepackage{a4wide,verbatim,graphicx,upquote,microtype} \usepackage{color} From 3c843b8717ec4b4d5746dfc07f2ada777cd14357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 22:22:34 +0200 Subject: [PATCH 15/20] Simple PDF generated - I can't make \include{} work with latex_document{} either. Instead, concatenate the files - Many packages missing ; I rewrote a trivial document. --- docs/BUILD | 24 +++++++++++++++++++++--- docs/manual.tex | 35 +++++++++++++++++++++-------------- docs/manual_end.tex | 2 ++ docs/manual_start.tex | 10 ++++++++++ docs/md/head.md | 3 ++- 5 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 docs/manual_end.tex create mode 100644 docs/manual_start.tex diff --git a/docs/BUILD b/docs/BUILD index f85484baf..fd8a1ae95 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -34,10 +34,28 @@ pandoc( to_format = "latex", ) +genrule( + name = "manual_full_tex", + srcs = [ + "manual_start.tex", + ":latex_content", + "manual_end.tex", + ], + outs = ["manual_full.tex"], + cmd = GENRULE_CONCATENATE, +) + latex_document( - name = "pdf", - srcs = ["manual.tex", ":latex_content"], - main = "manual.tex", + name = "manual", + srcs = [ + #"manual.tex", + # "minimal.tex", + # "manual_full.tex", + "@bazel_latex//packages:graphicx", + "@bazel_latex//packages:hyperref", + "@bazel_latex//packages:microtype", + ], + main = "manual_full.tex", ) # Replaces placeholders by their respective value. diff --git a/docs/manual.tex b/docs/manual.tex index 7f5f74f4d..f22380b3e 100644 --- a/docs/manual.tex +++ b/docs/manual.tex @@ -1,17 +1,22 @@ % The Latex template for the manual, when doc built with bazel -\documentclass[11pt] %{scrartcl} -\usepackage{a4wide,verbatim,graphicx,upquote,microtype} - -\usepackage{color} +\documentclass[11pt] +%{scrartcl} +%\usepackage{a4wide} +%\usepackage{verbatim} +%\usepackage{graphicx} % "@bazel_latex//packages:graphicx" +%\usepackage{upquote} +%\usepackage{microtype} % "@bazel_latex//packages:microtype" + +%\usepackage{color} \definecolor{lcol}{rgb}{0,0,0.5} -\usepackage[unicode=true,bookmarks, - colorlinks=true,linkcolor=lcol,citecolor=lcol, - filecolor=lcol,urlcolor=lcol, - pdfauthor={Gerwin Klein, Steve Rowe, Regis Decamps}, - pdftitle={JFlex User's Manual}, - pdfkeywords={Java, scanner, lexer, scanner generator}, - plainpages=false]{hyperref} +%\usepackage[unicode=true,bookmarks, +% colorlinks=true,linkcolor=lcol,citecolor=lcol, +% filecolor=lcol,urlcolor=lcol, +% pdfauthor={Gerwin Klein, Steve Rowe, Regis Decamps}, +% pdftitle={JFlex User's Manual}, +% pdfkeywords={Java, scanner, lexer, scanner generator}, +% plainpages=false]{hyperref} % pandoc packages @@ -53,8 +58,10 @@ \sffamily {\Large The Fast Lexical Analyser Generator}\\ \smallskip\smallskip -Copyright \copyright\ 1998--2018 by \href{http://www.doclsf.de}{Gerwin Klein}, -Steve Rowe, and \href{http://regis.decamps.info/}{R\'egis D\'ecamps}. +Copyright \copyright\ 1998--2018 +by \href{http://www.doclsf.de}{Gerwin Klein}, +Steve Rowe, +and \href{http://regis.decamps.info/}{R\'egis D\'ecamps}. \vspace*{15ex} {\Huge \sffamily \bfseries JFlex User's Manual}\\ @@ -66,7 +73,7 @@ \tableofcontents \newpage -\include{manual_content} +\include{content} \newpage diff --git a/docs/manual_end.tex b/docs/manual_end.tex new file mode 100644 index 000000000..1aad1859f --- /dev/null +++ b/docs/manual_end.tex @@ -0,0 +1,2 @@ + +\end{document} \ No newline at end of file diff --git a/docs/manual_start.tex b/docs/manual_start.tex new file mode 100644 index 000000000..455843755 --- /dev/null +++ b/docs/manual_start.tex @@ -0,0 +1,10 @@ +\documentclass{article} +\usepackage{hyperref} + +% pandoc now uses \tightlist +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + +\newcommand{\textquotesingle}{'} + +\begin{document} diff --git a/docs/md/head.md b/docs/md/head.md index 922e2a43d..87094a07d 100644 --- a/docs/md/head.md +++ b/docs/md/head.md @@ -3,9 +3,10 @@ title: JFlex User's Manual bibliography: manual.bib --- -
TODO: Restore image +
+ The Fast Lexical Analyser Generator Copyright © 1998–2018 by From aee983be27df0745de6e464df97148494ed48d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 22:53:59 +0200 Subject: [PATCH 16/20] Build the doc with bazel.sh --- .travis.yml | 2 +- docs/BUILD | 12 +- docs/template.tex | 355 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/bazel.sh | 5 +- 4 files changed, 360 insertions(+), 14 deletions(-) create mode 100644 docs/template.tex diff --git a/.travis.yml b/.travis.yml index 2c0006ca7..a1689d6ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ matrix: - name: "👴 Examples (mvn, ant, make) — JDK7" script: scripts/test-examples.sh jdk: openjdk7 - - name: "😎 Examples (with Bazel)" + - name: "💚 Bazel (Examples and documentation)" language: generic script: - scripts/mvn-install-fastbuild.sh diff --git a/docs/BUILD b/docs/BUILD index fd8a1ae95..ba3b0bd3c 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -32,17 +32,7 @@ pandoc( from_format = "markdown", output = "content.tex", # If changed, then change \include{} in manual.tex to_format = "latex", -) - -genrule( - name = "manual_full_tex", - srcs = [ - "manual_start.tex", - ":latex_content", - "manual_end.tex", - ], - outs = ["manual_full.tex"], - cmd = GENRULE_CONCATENATE, + options = ["--template", ""], ) latex_document( diff --git a/docs/template.tex b/docs/template.tex new file mode 100644 index 000000000..ec208bb35 --- /dev/null +++ b/docs/template.tex @@ -0,0 +1,355 @@ +% Latex template for pandoc +% https://gist.github.com/michaelt/1017790 + +%!TEX TS-program = xelatex +\documentclass[12pt]{scrartcl} + +% The declaration of the document class: + +% The second line here, i.e. +% \documentclass[12pt]{scrartcl} +% is a standard LaTeX document class declaration: +% we say what kind of document we are making in curly brackets, +% and specify any options in square brackets. + +% (The previous line is a pseudo-comment, declaring that we will +% use the special XeTeX machinery for its more extensive font list +% and its use of unicode; +% in general, LaTeX 'comments' like this one +% begin with % and end with a linebreak.) + +% Note that there we have nothing in the nature of a template; +% it's just a standard bit of LaTeX pandoc will copy unaltered into the +% LaTeX file it is writing. But suppose you wrote something +% more akin to the corresponding line in Pandoc's default +% latex.template file, say: + +% \documentclass$if(fontsize)$[$fontsize$]$endif${scrartcl} + +% then you would have invented a 'variable', fontsize, +% and could write things like + +% `markdown2pdf my.txt --xetex --variable=fontsize:12pt -o my.pdf` or +% `pandoc -r markdown -w html my.txt -s --xetex --variable=fontsize:24pt -o my.tex`. + +% If we specified --variable-fontsize:12, then template substitution +% would yield a LaTeX document beginning +% \documentclass[12pt]{scrarcl} +% which is just what we said anyway. +% But we could also specify a different fontsize. + +% I don't use this `--variable=....`functionality myself; +% I have a couple of basic templates I call with +% `--template=whatever.template` which I can also +% easily inspect to adjust things like font size as I please. + +% While we are discussing the declaration of the document class... +% here's an alternative command for two column landscape, +% not bad for some purposes. (If you strike the word 'landscape' +% you will have two narrow newspaperlike +% columns; scientists like that, because irrationality must +% show itself somewhere): +%\documentclass[12pt,twocolumn,landscape]{scrartcl} +% Columns are too close together in LaTeX so we add this +% `columnsep` command: +%\setlength{\columnsep}{.5in} + + +% I use the special 'komascript' article class "scrartcl" +% reasons I can't entirely remember; I'm not sure it's that great. +% One reason is the unimportant one that, like many classes, +% it allows very big fonts which are convenient for booklet printing +% in the idiotic American way by shrinking letterpaper pages. + +% the standard minimal LaTeX 'article' class declaration would be something like: + +% \documentclass[12pt]{article} + +% or for big type: + +% \documentclass[24pt]{extarticle} + +% but these restrict you to old-fashioned LaTeX materials. +% Note that Kieran Healy uses the swank 'Memoir' class, +% \documentclass[11pt,article,oneside]{memoir} +% which might be worth a look. + +% Enough about the document class. + +% -- We are in swanky unicode, XeTeX land, and must now import these packages: +\usepackage{fontspec,xltxtra,xunicode} +% fontspec means we can specify pretty much any font. +% Because we are using XeTeX material, +% this template needs to be called with the `--xetex` flag. + + +% Symbols: +% Pandoc imports the extensive `amsmath` collection of symbols +% for typesetting ordinary math. +\usepackage{amsmath} +% if you use exotic symbols you need to import specific packages, eg. for +% electrical engineering diagrams, musical notation, exotic currency symbols, +% the unspeakable rites of freemasonry etc. + + +% `babel`: +% The `babel` package, among other things, lets you determine what +% language you are using in a given stretch of text, so that typesetting +% will go well. Here we specify that mostly, we are speaking English: +\usepackage[english]{babel} + + +% Margins, etc: +% the `geometry` package makes for convenient adjusting of margins, which is what +% you asked about. Of course it can do much more, even make coffee for you: +\usepackage{geometry} +\geometry{verbose,letterpaper,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm} +% so if you just keep a copy of this template in the directory you are working in, you +% can adjust the margins by going into this file and messing with the margins. +% the syntax is very unforgiving, but permits 3cm and 2.5in and some other things. + + +% Font: +% Here I set my main font, which is an Apple Corporation Exclusive, golly. + +% \setmainfont{Hoefler Text} +% \setromanfont[Mapping=tex-text,Contextuals={NoWordInitial,NoWordFinal,NoLineInitial,NoLineFinal},Ligatures={NoCommon}]{Hoefler Text} + +% Hoefler Text is okay, but note the long discussion of 'contextuals' which is necessary to cools off +% some of its show-offy properties. (You can make your essay look like the +% Declaration of Independence by specifying e.g. Ligatures={Rare} ) +% If you have a copy you might try it; as it is +% I will comment it out and supply something more certain to be around: + +\setmainfont{Times Roman} + +% Properly one should specify a sanserif font and a monospace font +% see e.g. the example of Kieran Healy: +% \setromanfont[Mapping=tex-text,Numbers=OldStyle]{Minion Pro} +% \setsansfont[Mapping=tex-text]{Minion Pro} +% \setmonofont[Mapping=tex-text,Scale=0.8]{Pragmata} + +% But I hate sanserif fonts, and anyway there are defaults. + + + +% Heading styles: +% These commands keep the koma system from making stupid sans serif section headings +\setkomafont{title}{\rmfamily\mdseries\upshape\normalsize} +\setkomafont{sectioning}{\rmfamily\mdseries\upshape\normalsize} +\setkomafont{descriptionlabel}{\rmfamily\mdseries\upshape\normalsize} + + + +% I'm puzzled why I have this foonote speciality, +% I wonder if it's part of my problem I've been having, but wont look +% into it now. +\usepackage[flushmargin]{footmisc} +% \usepackage[hang,flushmargin]{footmisc} + + +% So much for my personal template. + + +% Everything that follows is copied from the pandoc default template: +% I will interpolate a few comments, the comments that are in +% the default template will be marked % -- + +% Paragraph format: +% Pandoc prefers unindented paragraphs in the European style: +\setlength{\parindent}{0pt} +% ... with paragraph breaks marked by a slight lengthening of +% the space between paragraphs: +\setlength{\parskip}{6pt plus 2pt minus 1pt} + +% Page format: +\pagestyle{plain} +% The default `plain` pagestyle just numbers the pages, +% whereas +% \pagestyle{empty} +% would give you no numbering. +% After one-million man-years of macro-composition, +% there are also fancy pagestyles with much wilder options +% for headers and footers, of course. + +% Footnotes +% if you have code in your footnotes, the million macro march +% kind of bumps into itself. +% Pandoc, having just rendered your text into LaTeX, +% knows whether the 'variable' `verbatim-in-note` is True, and +% If it is, it asks for a LaTeX package that solves the dilemma: +$if(verbatim-in-note)$ +\usepackage{fancyvrb} +$endif$ + +% Lists formatting: +% note sure what 'fancy enums' are; something to do with lists, +% as the further comment suggests: +$if(fancy-enums)$ +% -- Redefine labelwidth for lists; otherwise, the enumerate package will cause +% -- markers to extend beyond the left margin. +\makeatletter\AtBeginDocument{% + \renewcommand{\@listi} + {\setlength{\labelwidth}{4em}} +}\makeatother +\usepackage{enumerate} +$endif$ + + +% Table formatting: +% What if you make a table? -- Pandoc knows, of course, and +% then declares that its variable `table` is True and +% imports a table package suitable to its pleasantly simple tables. +% Needless to say infinitely complicated tables are possible in +% LaTeX with suitable packages. We are spared the temptation: + +$if(tables)$ +\usepackage{array} + +% Continuing on the topic of tables ... (we havent reached `endif`). +% The commented out line below is in the default pandoc latex.template. +% Some unpleasantness with table formatting must be corrected. + +% -- This is needed because raggedright in table elements redefines \\: +\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp} +\let\PBS=\PreserveBackslash + +$endif$ + + +% Subscripts: +% Pandoc remembers whether you used subscripts, assigning True to +% its `subscript` variable +% It then needs to adopt a default with an incantation like this: +$if(subscript)$ +\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}} +$endif$ + + +% Web-style links: + +% markdown inclines us to use links, since our texts can be made into html. +% Why not have clickable blue links even in +% learned, scientific, religious, juridical, poetical and other suchlike texts? +% Never mind that they have been proven to destroy the nervous system! + +% First, what about the fact that links like http://example.com are +% technically code and thus must not be broken across lines? +% [breaklinks=true] to the rescue! + +% Nowadays LaTeX can handle all of this with another half million macros: + +\usepackage[breaklinks=true]{hyperref} +\hypersetup{colorlinks,% +citecolor=blue,% +filecolor=blue,% +linkcolor=blue,% +urlcolor=blue} +$if(url)$ +\usepackage{url} +$endif$ + + + +% Images. +% In ye olde LaTeX one could only import a limited range of image +% types, e.g. the forgotten .eps files. Or else one simply drew the image with suitable +% commands and drawing packages. Today we want to import .jpg files we make with +% our smart phones or whatever: + +$if(graphics)$ +\usepackage{graphicx} +% -- We will generate all images so they have a width \maxwidth. This means +% -- that they will get their normal width if they fit onto the page, but +% -- are scaled down if they would overflow the margins. +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth +\else\Gin@nat@width\fi} +\makeatother +\let\Oldincludegraphics\includegraphics +\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}} +$endif$ + + + +% Section numbering. +% Here again is a variable you can specify on the commandline +% `markdown2pdf my.txt --number-sections --xetex --template=/wherever/this/is -o my.pdf` +$if(numbersections)$ +$else$ +\setcounter{secnumdepth}{0} +$endif$ + +% Footnotes: +% Wait, didn't we already discuss the crisis of code in footnotes? +% Evidently the order of unfolding of macros required that +% we import a package to deal with them earlier +% and issue a command it defines now. (Or maybe that's not the reason; +% very often the order does matter as the insane system of macro expansion +% must take place by stages.) +$if(verbatim-in-note)$ +\VerbatimFootnotes % -- allows verbatim text in footnotes +$endif$ + +% Other stuff you specify on the command line: +% You can include stuff for the header from a file specified on the command line; +% I've never done this, but that stuff will go here: +$for(header-includes)$ +$header-includes$ +$endfor$ + +% Title, authors, date. +% If you specified title authors and date at the start of +% your pandoc-markdown file, pandoc knows the 'values' of the +% variables: title authors date and fills them in. + +$if(title)$ +\title{$title$} +$endif$ +\author{$for(author)$$author$$sep$\\$endfor$} +$if(date)$ +\date{$date$} +$endif$ + +% At last: +% The document itself!: + +% After filling in all these blanks above, or erasing them +% where they are not needed, Pandoc has finished writing the +% famous LaTeX *preamble* for your document. +% Now comes the all-important command \begin{document} +% which as you can see, will be paired with an \end{document} at the end. +% Pandoc knows whether you have a title, and has already +% specified what it is; if so, it demands that the title be rendered. +% Pandoc knows whether you want a table of contents, you +% specify this on the command line. +% Then, after fiddling with alignments, there comes the real +% business: pandoc slaps its rendering of your text in the place of +% the variable `body` +% It then concludes the document it has been writing. + +\begin{document} + + +$if(title)$ +\maketitle +$endif$ + +$if(toc)$ +\tableofcontents + +$endif$ + + +$if(alignment)$ +\begin{$alignment$} +$endif$ + +$body$ + +%$if(alignment)$ +\end{$alignment$} +$endif$ + + +\end{document} diff --git a/scripts/bazel.sh b/scripts/bazel.sh index 8ce01d5b9..a4384de84 100755 --- a/scripts/bazel.sh +++ b/scripts/bazel.sh @@ -27,11 +27,12 @@ $BAZEL info logi "Build everything" logi "================" -$BAZEL build //... +$BAZEL build //jflex/examples/... +$BAZEL build //docs/... logi "Test everything" logi "===============" -$BAZEL test //... +$BAZEL test //jflex/examples/... if [[ -n "$CI" ]]; then From c1f9a19f53c2edc58685d6644f7fd5a0e24b4466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 22:56:04 +0200 Subject: [PATCH 17/20] Fix bazel.sh for new third_party location --- scripts/bazel.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bazel.sh b/scripts/bazel.sh index a4384de84..f9a673e35 100755 --- a/scripts/bazel.sh +++ b/scripts/bazel.sh @@ -17,8 +17,8 @@ fi logi "Copy JFlex jar in //third_party" logi "===============================" # NB This will fail if there are multiple versions of the jflex jar. -cp "$BASEDIR"/jflex/target/jflex-1.*.jar "$BASEDIR"/jflex/examples/third_party/de/jflex/jflex.jar -cp "$BASEDIR"/cup/cup_runtime/target/cup_runtime-*.jar "$BASEDIR"/jflex/examples/third_party/de/jflex/cup_runtime.jar +cp "$BASEDIR"/jflex/target/jflex-1.*.jar "$BASEDIR"/third_party/de/jflex/jflex.jar +cp "$BASEDIR"/cup/cup_runtime/target/cup_runtime-*.jar "$BASEDIR"/third_party/de/jflex/cup_runtime.jar logi "Start Bazel" logi "===========" From 56827d269ff77ddf9c3da2c55b8cc19f8372df52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 22:58:14 +0200 Subject: [PATCH 18/20] Restore the latex concatenation. pandoc(0 rule doesn't uspport templates yet. --- docs/BUILD | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/BUILD b/docs/BUILD index ba3b0bd3c..fd8a1ae95 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -32,7 +32,17 @@ pandoc( from_format = "markdown", output = "content.tex", # If changed, then change \include{} in manual.tex to_format = "latex", - options = ["--template", ""], +) + +genrule( + name = "manual_full_tex", + srcs = [ + "manual_start.tex", + ":latex_content", + "manual_end.tex", + ], + outs = ["manual_full.tex"], + cmd = GENRULE_CONCATENATE, ) latex_document( From f11756c5a5520be47c9a60be41cc40fc6296e5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Fri, 12 Oct 2018 23:18:07 +0200 Subject: [PATCH 19/20] No use of thempalte, this is not supported yet by the bazel rule. --- docs/template.tex | 355 ---------------------------------------------- 1 file changed, 355 deletions(-) delete mode 100644 docs/template.tex diff --git a/docs/template.tex b/docs/template.tex deleted file mode 100644 index ec208bb35..000000000 --- a/docs/template.tex +++ /dev/null @@ -1,355 +0,0 @@ -% Latex template for pandoc -% https://gist.github.com/michaelt/1017790 - -%!TEX TS-program = xelatex -\documentclass[12pt]{scrartcl} - -% The declaration of the document class: - -% The second line here, i.e. -% \documentclass[12pt]{scrartcl} -% is a standard LaTeX document class declaration: -% we say what kind of document we are making in curly brackets, -% and specify any options in square brackets. - -% (The previous line is a pseudo-comment, declaring that we will -% use the special XeTeX machinery for its more extensive font list -% and its use of unicode; -% in general, LaTeX 'comments' like this one -% begin with % and end with a linebreak.) - -% Note that there we have nothing in the nature of a template; -% it's just a standard bit of LaTeX pandoc will copy unaltered into the -% LaTeX file it is writing. But suppose you wrote something -% more akin to the corresponding line in Pandoc's default -% latex.template file, say: - -% \documentclass$if(fontsize)$[$fontsize$]$endif${scrartcl} - -% then you would have invented a 'variable', fontsize, -% and could write things like - -% `markdown2pdf my.txt --xetex --variable=fontsize:12pt -o my.pdf` or -% `pandoc -r markdown -w html my.txt -s --xetex --variable=fontsize:24pt -o my.tex`. - -% If we specified --variable-fontsize:12, then template substitution -% would yield a LaTeX document beginning -% \documentclass[12pt]{scrarcl} -% which is just what we said anyway. -% But we could also specify a different fontsize. - -% I don't use this `--variable=....`functionality myself; -% I have a couple of basic templates I call with -% `--template=whatever.template` which I can also -% easily inspect to adjust things like font size as I please. - -% While we are discussing the declaration of the document class... -% here's an alternative command for two column landscape, -% not bad for some purposes. (If you strike the word 'landscape' -% you will have two narrow newspaperlike -% columns; scientists like that, because irrationality must -% show itself somewhere): -%\documentclass[12pt,twocolumn,landscape]{scrartcl} -% Columns are too close together in LaTeX so we add this -% `columnsep` command: -%\setlength{\columnsep}{.5in} - - -% I use the special 'komascript' article class "scrartcl" -% reasons I can't entirely remember; I'm not sure it's that great. -% One reason is the unimportant one that, like many classes, -% it allows very big fonts which are convenient for booklet printing -% in the idiotic American way by shrinking letterpaper pages. - -% the standard minimal LaTeX 'article' class declaration would be something like: - -% \documentclass[12pt]{article} - -% or for big type: - -% \documentclass[24pt]{extarticle} - -% but these restrict you to old-fashioned LaTeX materials. -% Note that Kieran Healy uses the swank 'Memoir' class, -% \documentclass[11pt,article,oneside]{memoir} -% which might be worth a look. - -% Enough about the document class. - -% -- We are in swanky unicode, XeTeX land, and must now import these packages: -\usepackage{fontspec,xltxtra,xunicode} -% fontspec means we can specify pretty much any font. -% Because we are using XeTeX material, -% this template needs to be called with the `--xetex` flag. - - -% Symbols: -% Pandoc imports the extensive `amsmath` collection of symbols -% for typesetting ordinary math. -\usepackage{amsmath} -% if you use exotic symbols you need to import specific packages, eg. for -% electrical engineering diagrams, musical notation, exotic currency symbols, -% the unspeakable rites of freemasonry etc. - - -% `babel`: -% The `babel` package, among other things, lets you determine what -% language you are using in a given stretch of text, so that typesetting -% will go well. Here we specify that mostly, we are speaking English: -\usepackage[english]{babel} - - -% Margins, etc: -% the `geometry` package makes for convenient adjusting of margins, which is what -% you asked about. Of course it can do much more, even make coffee for you: -\usepackage{geometry} -\geometry{verbose,letterpaper,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm} -% so if you just keep a copy of this template in the directory you are working in, you -% can adjust the margins by going into this file and messing with the margins. -% the syntax is very unforgiving, but permits 3cm and 2.5in and some other things. - - -% Font: -% Here I set my main font, which is an Apple Corporation Exclusive, golly. - -% \setmainfont{Hoefler Text} -% \setromanfont[Mapping=tex-text,Contextuals={NoWordInitial,NoWordFinal,NoLineInitial,NoLineFinal},Ligatures={NoCommon}]{Hoefler Text} - -% Hoefler Text is okay, but note the long discussion of 'contextuals' which is necessary to cools off -% some of its show-offy properties. (You can make your essay look like the -% Declaration of Independence by specifying e.g. Ligatures={Rare} ) -% If you have a copy you might try it; as it is -% I will comment it out and supply something more certain to be around: - -\setmainfont{Times Roman} - -% Properly one should specify a sanserif font and a monospace font -% see e.g. the example of Kieran Healy: -% \setromanfont[Mapping=tex-text,Numbers=OldStyle]{Minion Pro} -% \setsansfont[Mapping=tex-text]{Minion Pro} -% \setmonofont[Mapping=tex-text,Scale=0.8]{Pragmata} - -% But I hate sanserif fonts, and anyway there are defaults. - - - -% Heading styles: -% These commands keep the koma system from making stupid sans serif section headings -\setkomafont{title}{\rmfamily\mdseries\upshape\normalsize} -\setkomafont{sectioning}{\rmfamily\mdseries\upshape\normalsize} -\setkomafont{descriptionlabel}{\rmfamily\mdseries\upshape\normalsize} - - - -% I'm puzzled why I have this foonote speciality, -% I wonder if it's part of my problem I've been having, but wont look -% into it now. -\usepackage[flushmargin]{footmisc} -% \usepackage[hang,flushmargin]{footmisc} - - -% So much for my personal template. - - -% Everything that follows is copied from the pandoc default template: -% I will interpolate a few comments, the comments that are in -% the default template will be marked % -- - -% Paragraph format: -% Pandoc prefers unindented paragraphs in the European style: -\setlength{\parindent}{0pt} -% ... with paragraph breaks marked by a slight lengthening of -% the space between paragraphs: -\setlength{\parskip}{6pt plus 2pt minus 1pt} - -% Page format: -\pagestyle{plain} -% The default `plain` pagestyle just numbers the pages, -% whereas -% \pagestyle{empty} -% would give you no numbering. -% After one-million man-years of macro-composition, -% there are also fancy pagestyles with much wilder options -% for headers and footers, of course. - -% Footnotes -% if you have code in your footnotes, the million macro march -% kind of bumps into itself. -% Pandoc, having just rendered your text into LaTeX, -% knows whether the 'variable' `verbatim-in-note` is True, and -% If it is, it asks for a LaTeX package that solves the dilemma: -$if(verbatim-in-note)$ -\usepackage{fancyvrb} -$endif$ - -% Lists formatting: -% note sure what 'fancy enums' are; something to do with lists, -% as the further comment suggests: -$if(fancy-enums)$ -% -- Redefine labelwidth for lists; otherwise, the enumerate package will cause -% -- markers to extend beyond the left margin. -\makeatletter\AtBeginDocument{% - \renewcommand{\@listi} - {\setlength{\labelwidth}{4em}} -}\makeatother -\usepackage{enumerate} -$endif$ - - -% Table formatting: -% What if you make a table? -- Pandoc knows, of course, and -% then declares that its variable `table` is True and -% imports a table package suitable to its pleasantly simple tables. -% Needless to say infinitely complicated tables are possible in -% LaTeX with suitable packages. We are spared the temptation: - -$if(tables)$ -\usepackage{array} - -% Continuing on the topic of tables ... (we havent reached `endif`). -% The commented out line below is in the default pandoc latex.template. -% Some unpleasantness with table formatting must be corrected. - -% -- This is needed because raggedright in table elements redefines \\: -\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp} -\let\PBS=\PreserveBackslash - -$endif$ - - -% Subscripts: -% Pandoc remembers whether you used subscripts, assigning True to -% its `subscript` variable -% It then needs to adopt a default with an incantation like this: -$if(subscript)$ -\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}} -$endif$ - - -% Web-style links: - -% markdown inclines us to use links, since our texts can be made into html. -% Why not have clickable blue links even in -% learned, scientific, religious, juridical, poetical and other suchlike texts? -% Never mind that they have been proven to destroy the nervous system! - -% First, what about the fact that links like http://example.com are -% technically code and thus must not be broken across lines? -% [breaklinks=true] to the rescue! - -% Nowadays LaTeX can handle all of this with another half million macros: - -\usepackage[breaklinks=true]{hyperref} -\hypersetup{colorlinks,% -citecolor=blue,% -filecolor=blue,% -linkcolor=blue,% -urlcolor=blue} -$if(url)$ -\usepackage{url} -$endif$ - - - -% Images. -% In ye olde LaTeX one could only import a limited range of image -% types, e.g. the forgotten .eps files. Or else one simply drew the image with suitable -% commands and drawing packages. Today we want to import .jpg files we make with -% our smart phones or whatever: - -$if(graphics)$ -\usepackage{graphicx} -% -- We will generate all images so they have a width \maxwidth. This means -% -- that they will get their normal width if they fit onto the page, but -% -- are scaled down if they would overflow the margins. -\makeatletter -\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth -\else\Gin@nat@width\fi} -\makeatother -\let\Oldincludegraphics\includegraphics -\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}} -$endif$ - - - -% Section numbering. -% Here again is a variable you can specify on the commandline -% `markdown2pdf my.txt --number-sections --xetex --template=/wherever/this/is -o my.pdf` -$if(numbersections)$ -$else$ -\setcounter{secnumdepth}{0} -$endif$ - -% Footnotes: -% Wait, didn't we already discuss the crisis of code in footnotes? -% Evidently the order of unfolding of macros required that -% we import a package to deal with them earlier -% and issue a command it defines now. (Or maybe that's not the reason; -% very often the order does matter as the insane system of macro expansion -% must take place by stages.) -$if(verbatim-in-note)$ -\VerbatimFootnotes % -- allows verbatim text in footnotes -$endif$ - -% Other stuff you specify on the command line: -% You can include stuff for the header from a file specified on the command line; -% I've never done this, but that stuff will go here: -$for(header-includes)$ -$header-includes$ -$endfor$ - -% Title, authors, date. -% If you specified title authors and date at the start of -% your pandoc-markdown file, pandoc knows the 'values' of the -% variables: title authors date and fills them in. - -$if(title)$ -\title{$title$} -$endif$ -\author{$for(author)$$author$$sep$\\$endfor$} -$if(date)$ -\date{$date$} -$endif$ - -% At last: -% The document itself!: - -% After filling in all these blanks above, or erasing them -% where they are not needed, Pandoc has finished writing the -% famous LaTeX *preamble* for your document. -% Now comes the all-important command \begin{document} -% which as you can see, will be paired with an \end{document} at the end. -% Pandoc knows whether you have a title, and has already -% specified what it is; if so, it demands that the title be rendered. -% Pandoc knows whether you want a table of contents, you -% specify this on the command line. -% Then, after fiddling with alignments, there comes the real -% business: pandoc slaps its rendering of your text in the place of -% the variable `body` -% It then concludes the document it has been writing. - -\begin{document} - - -$if(title)$ -\maketitle -$endif$ - -$if(toc)$ -\tableofcontents - -$endif$ - - -$if(alignment)$ -\begin{$alignment$} -$endif$ - -$body$ - -%$if(alignment)$ -\end{$alignment$} -$endif$ - - -\end{document} From a766ce1fac3679175e0f99f7681226e0ff4b115f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Sat, 13 Oct 2018 01:46:22 +0200 Subject: [PATCH 20/20] Remove useless cd jflex/examples in bazel.sh --- WORKSPACE | 7 +++---- scripts/bazel.sh | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 797efe1bd..b17bc9e3e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,7 +1,7 @@ # Workspace file for the Bazel build system # https://bazel.build/ -# JFlex itself is not built with Bazel, but some examples and the documentation do. +# JFlex itself is not built with Bazel, but some examples and the documentation are. load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( @@ -35,9 +35,7 @@ load("@bazel_pandoc//:repositories.bzl", "pandoc_repositories") pandoc_repositories() - -# third-party libraries - +# latex rule to build PDF from tex files http_archive( name = "bazel_latex", @@ -50,6 +48,7 @@ load("@bazel_latex//:repositories.bzl", "latex_repositories") latex_repositories() # Third-party depenencies + maven_jar( name = "com_google_truth_truth", artifact = "com.google.truth:truth:0.36", diff --git a/scripts/bazel.sh b/scripts/bazel.sh index 01cc7937e..eeade1798 100755 --- a/scripts/bazel.sh +++ b/scripts/bazel.sh @@ -16,7 +16,6 @@ fi logi "Start Bazel" logi "===========" -cd "$BASEDIR"/jflex/examples $BAZEL info logi "Build everything"