Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a PDF file from Markdown documents (md2pdf) #11257

Draft
wants to merge 187 commits into
base: main
Choose a base branch
from

Conversation

michelou
Copy link
Contributor

@michelou michelou commented Jan 30, 2021

WIP

The pandoc subproject make it possible to create a PDF file (e.g. scala3_reference.pdf) from the Markdown documents of the Scala 3 documentation (internals, reference, usage).

Todo :

  • fix arguments passed to the Docker container
  • test (and improve) workflow file pandoc.yaml to run CI job with GitHub Actions.
  • improve documentation (Docker, GitHub Actions)

Related to :

@SethTisue
Copy link
Member

I don't think there's anything here I can meaningfully review (I don't know Docker), but I'm delighted to see it happening.

@michelou michelou removed the request for review from SethTisue January 31, 2021 09:04
@michelou
Copy link
Contributor Author

I don't think there's anything here I can meaningfully review (I don't know Docker), but I'm delighted to see it happening.

That's fair. My primary intent was to let you know things are moving forward. I've removed your name from the reviewers.

@liufengyun liufengyun self-assigned this Feb 2, 2021
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work 👍

***

*[mics](https://github.com/michelou/)/January 2021* [**▲**](#top "Back to top")
<span id="bottom">&nbsp;</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Back to top seems not very useful, maybe remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While your comment is justified for people working with 20+ inch screens, I and others I guess are used to read online docs with a 5.8 inch cell phone, in which case this tiny button is very practical. I let you decide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, it's fine to keep it.

pandoc/README.md Outdated
<table style="margin-top:-10px; max-width:650px;">
<tr>
<td><b>Input directories</b></td>
<td><code>dotty/docs/docs/&lt;project&gt;/</code><br/><code>dotty/pandoc/data/</code></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<td><code>dotty/docs/docs/&lt;project&gt;/</code><br/><code>dotty/pandoc/data/</code></td>
<td><code>docs/docs/&lt;project&gt;/</code><br/><code>pandoc/data/</code></td>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pandoc/README.md Outdated
</tr>
<tr>
<td><b>Output directory</b></td>
<td><code>dotty/out/pandoc/</code></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<td><code>dotty/out/pandoc/</code></td>
<td><code>out/pandoc/</code></td>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done,

---
layout: doc-page
title: "Scala 3 Internals"
titlegraphic: ../out/pandoc/images/scala-spiral.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May it refer to pandoc/data/images/scala-spiral.png directly?

Copy link
Contributor Author

@michelou michelou Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

md2pdf starts with a preprocessing phase which transforms :

  • cross-references found in the Markdown files (e.g. reference) to named anchors
  • references to image files stored in pandoc/data/images/ (e.g. scala-spiral.png) to relative paths.

In short all references not starting with https:// are transformed before calling the pandoc command line tool. In the output directory out/pandoc/ both directories images/ and src_managed/ are expected to be at the same level :

  • out/pandoc/images/
  • out/pandoc/src_managed/
  • out/pandoc/scala3_reference.pdf

layout: doc-page
title: "Scala 3 Internals"
titlegraphic: ../out/pandoc/images/scala-spiral.png
author: Martin Odersky and al.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
author: Martin Odersky and al.
author: Martin Odersky et al.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

layout: doc-page
title: "Scala 3 Reference"
titlegraphic: ../out/pandoc/images/scala-spiral.png
author: Martin Odersky and al.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
author: Martin Odersky and al.
author: Martin Odersky et al.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


This project is located at the root of the [`lampepfl/dotty`][github_dotty] repository, at the same level as the [`Scala3doc`][github_scala3doc] project.

## <span id="structure">Directory structure</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to merge this with pandoc/README, so that the reader has an overview on first read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,168 @@
# <span id="top">More about TeX Live</span> <span style="size:25%;"><a href="../README.md" title="Back to README">↩</a></span>
<!-- created by mics (https://github.com/michelou/) on December 2020 -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this document necessary given that we have the docker image?

@@ -0,0 +1,218 @@
@rem ## Created by mics (https://github.com/michelou/) on December 2020.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If image can be built by Linux/MacOS and published, then we don't need the script to build the image on Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My wish here is to offer different ways to developers to generate a PDF file from the Markdown files before they publish their changes (more details per email).


We provide two commands for MacOS/Ubuntu as well as their equivalents for MS Windows :
- for *interactive users* :<br/>[`build {<option>|<subcommand>}`](./build) (resp. [`build.bat`](./build.bat) on MS Windows)<br/><span style="font-size:80%;">(option `-help` displays the available options/subcommands).</span>
- for *automated tasks* (primarily, but not exclusively) :<br/>[`md2pdf [<project>]`](./md2pdf) (resp. [`md2pdf.bat`](./md2pdf.bat) on MS Windows)<br/><span style="font-size:80%;">(default value for `<project>` : `reference`).</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've wondering, instead of having two commands build and md2pdf, can we have the same command for both local machines and cloud CI, assuming that both will use a published docker image?

Copy link
Contributor Author

@michelou michelou Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion is right.

The existence of both commands build and md2pdf stems in part from my own background as a long-standing developer. Let me try to advocate the case (for fun) :

  • as a preamble the existance of both scripts is not directly linked to Docker.
  • build is a user-friendly wrapper script; it calls md2pdf but it also
    • provides some options (e.g. -verbose and -debug) and some subcommands (e.g. clean and view on MS Windows); I typically run command build -timer -verbose clean view to generate file scala3_reference.pdf on my Win10 laptop.
    • provides conditional compilation; the output file (e.g. scala3_reference.pdf) is generated depending on input file timestamps.
  • md2pdf is the minimal script for running pandoc with the appropriate settings.

In the context of the Dotty project, we can indeed have only one shell script : md2pdf (and may be md2pdf.bat).

NB. I could even omit several type checks environment checks inmd2pdf assuming users can help themselves in case of errors.

michelou and others added 17 commits February 2, 2021 23:10
- Register class type parameters from outer contexts in typedDefdef.
- Remove a condition to support gadt approximation for class type parameters.
- Add test cases in tests/pos/class-gadt.
- Ignore test cases tests/pos/i4345.scala and i5735.scala (issue scala#11220 and scala#11221)
Co-authored-by: Allan Renucci <allanrenucci@users.noreply.github.com>
Make sure that something is a language import if and only if it
looks like one. i.e. is of one of the forms

    import language.xyz
    import scala.language.xyz
    import _root_.scala.language.xyz
Avoid a notation of "owner" when checking for a language feature. Instead,
allow qualified names for language features, e.g. `experimental.dependent".
The bit is set if

 - -Yexplicit-nulls is set
 - we are not in an `import.unsafeNulls` scope
@bishabosha
Copy link
Member

Hi @michelou do you have any time to continue working on this?

@anatoliykmetyuk
Copy link
Contributor

@michelou what's the status on this one? Are you still working on it? Do you need someone to review it?

@michelou
Copy link
Contributor Author

@michelou what's the status on this one? Are you still working on it? Do you need someone to review it?

Short status is as follows :

  1. I regularly update the locally generated PDF file scala3_reference.pdf (last update: July 23, 2021) on my GitHub repository dotty-examples.
  2. I made no progress with the generation of the PDF file in a remote Docker container because I failed to upload the Docker image (NB. my internet connection is very limited, i.e. download ~10 Mbps / upload ~1 Mbps).

In resume I need a co-worker ready to help me with step 2.

@griggt
Copy link
Contributor

griggt commented Jul 28, 2021

@michelou I think I can help with getting the PDF generation working in Docker / CI. I have a branch from quite a while ago where I had this working....once I find it are you ok with me pushing the changes to this PR?

@michelou
Copy link
Contributor Author

@anatoliykmetyuk @liufengyun @griggt Today I updated my locally generated PDF file scala3_reference.pdf .

Next steps :

  • open one (or two) PR to integrate my changes to the Markdown files.
  • give another try with the PDF generation built upon a Docker image.

@michelou
Copy link
Contributor Author

michelou commented Apr 6, 2022

Here is an actualized version of the locally generated PDF file scala3_reference.pdf.

@griggt I finally have to bring myself to abandon my attempts with Docker. In short your help is welcome !
As explained in my previous messages all my work is contained in directory DOTTY_PROJECT_ROOT/pandoc/. If you agree we can discuss the next steps offline (aka. via email).

@griggt
Copy link
Contributor

griggt commented Apr 6, 2022

@michelou happy to help, but it may be days or weeks before I have a chance to look at this again.

@griggt griggt self-assigned this Apr 6, 2022
@ckipp01 ckipp01 marked this pull request as draft February 6, 2023 13:22
@ckipp01
Copy link
Member

ckipp01 commented May 10, 2023

Hello! It's been about a year of inactivity here, so I just wanted to check if this should be closed, if someone plans on returning to this, etc?

@michelou
Copy link
Contributor Author

I just updated my GitHub project to (locally) generate the actualized PDF file scala3_reference.pdf.
Otherwise, no progress on the Docker-side.

I plan to look at the recently added pages and submit a few additions/corrections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.