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

Introducing initial support for compile-time / runtime output for PDF books #507

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
755daff
Test script: detecting code block without associated project.
gusthoff Feb 20, 2021
ab7ea0d
Test script: fixing call to remove-tree.
gusthoff Feb 20, 2021
818d658
Test script: storing runtime output in "out" variable.
gusthoff Feb 20, 2021
9f7da80
Test script: adding support for storing build / runtime output.
gusthoff Feb 20, 2021
698b32d
Test script: adding handling of C code blocks.
gusthoff Feb 20, 2021
5f1ba9d
Test script: removing "ada-run" from list of classes that require "ru…
gusthoff Feb 20, 2021
cd36550
Test script: adding support for keeping all files generated by the sc…
gusthoff Feb 20, 2021
9583215
Sphinx: adding Python class for build / runtime output files.
gusthoff Feb 20, 2021
77cc430
Sphinx: integrating build / runtime output into LaTeX file (for PDF b…
gusthoff Feb 20, 2021
b1f3f83
Makefile: adding support for build / runtime output for PDF books.
gusthoff Feb 20, 2021
5b0009f
Editorial changes: removing unneeded instances of "ada-run" class.
gusthoff Feb 20, 2021
9d56419
Editorial changes: adding compile button to source-code blocks.
gusthoff Feb 20, 2021
35a9c12
Editorial changes: removing paragraphs from PDF version.
gusthoff Feb 20, 2021
c20bac6
Editorial changes: adding "ada-run" class to source-code examples.
gusthoff Feb 20, 2021
54c2c62
Test script: correcting compilation of C code block.
gusthoff Feb 20, 2021
927bbbd
Test script: importing glob
gusthoff Feb 20, 2021
b7405bc
Widget: adding C-related Sphinx classes.
gusthoff Feb 20, 2021
5b4250b
Test script: correcting creation of directory for build/runtime output.
gusthoff Feb 20, 2021
e31ce4d
Test script: fixing call to remove-tree in case of "keep files."
gusthoff Feb 20, 2021
49a1cc4
Test script: adding support for storing output of the prover.
gusthoff Feb 20, 2021
609671e
Widget: adding support for including output of the prover for PDF book.
gusthoff Feb 20, 2021
7634c2e
Correcting function prototype.
gusthoff Feb 20, 2021
088a708
Editorial change: correcting typo in project name of code blocks.
gusthoff Feb 20, 2021
2f7fc48
Test: adding missing class for expected error in C code.
gusthoff Feb 20, 2021
750e05a
GitHub actions: adding test of the build of PDF books.
gusthoff Feb 20, 2021
b18b689
GitHub actions: adding dependencies for PDF books.
gusthoff Feb 20, 2021
8bb43e4
GitHub actions: adding support for storing PDF books in artifact.
gusthoff Feb 26, 2021
ec3eef2
GitHub actions: limiting retention period to one day.
gusthoff Feb 26, 2021
426c461
GitHub actions: correcting path to PDF books.
gusthoff Feb 26, 2021
205bc01
GitHub actions: adding support for storing PDF books as artifact.
gusthoff Feb 26, 2021
0da9a61
Editorial changes: replacing attention block by admonition.
gusthoff Feb 26, 2021
1a1a445
Widget: reintroducing caption for source-code blocks in PDF books.
gusthoff Feb 26, 2021
09749f7
Test script: removing "using project" line from build output.
gusthoff Feb 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/sphinx-content-tests.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ jobs:
- name: Install OS Deps
run: |
sudo apt-get install -y \
graphviz
graphviz \
texlive-latex-base \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-fonts-extra \
latexmk \
texlive-xetex \
fonts-lmodern \
fonts-open-sans \
fonts-dejavu
- name: Install dependencies
run: yarn --frozen-lockfile
- name: ada-actions/toolchain
Expand All @@ -47,3 +57,12 @@ jobs:
run: make SPHINXOPTS="-W" test_engine
- name: Run SPHINX content tests
run: make -k test_content
- name: Build PDF books including build/runtime output
run: make pdf_books
- name: Archive PDF books in artifact
uses: actions/upload-artifact@v2
with:
name: learn-pdf-books
path: |
frontend/dist/pdf_books
retention-days: 1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ program in Ada and C:

[C]

.. code:: c cli_input run_button project=Courses.Ada_For_C_Embedded_Dev.Introduction.Add_Angles_C
.. code:: c cli_input run_button project=Courses.Ada_For_Embedded_C_Dev.Introduction.Add_Angles_C

!main.c
#include <stdio.h>
Expand Down Expand Up @@ -60,7 +60,7 @@ program in Ada and C:

[Ada]

.. code:: ada cli_input run_button project=Courses.Ada_For_C_Embedded_Dev.Introduction.Add_Angles_Ada
.. code:: ada cli_input run_button project=Courses.Ada_For_Embedded_C_Dev.Introduction.Add_Angles_Ada

with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ program:

[C]

.. code:: c run_button manual_chop project=Courses.Ada_For_C_Embedded_Dev.Perspective.Hello_World_C
.. code:: c run_button manual_chop project=Courses.Ada_For_Embedded_C_Dev.Perspective.Hello_World_C

!main.c
#include <stdio.h>
Expand All @@ -132,7 +132,7 @@ program:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Hello_World_Ada
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Hello_World_Ada

with Ada.Text_IO;

Expand Down Expand Up @@ -1945,7 +1945,7 @@ values from :ada:`'a'` to :ada:`'z'`:
!main.c
#include <stdio.h>

void main(void)
int main(int argc, const char * argv[])
{
char Arr [26];
char C = 'a';
Expand Down Expand Up @@ -2435,7 +2435,7 @@ Pointers to scalar objects in Ada and C look like:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Access_To_Scalars
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Access_To_Scalars

procedure Main is
type A_Int is access Integer;
Expand All @@ -2446,7 +2446,7 @@ Pointers to scalar objects in Ada and C look like:

[C]

.. code:: c run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Pointers_To_Scalars
.. code:: c run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Pointers_To_Scalars

!main.c
#include <stdlib.h>
Expand All @@ -2463,7 +2463,7 @@ In Ada, an initializer can be specified with the allocation by appending

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Access_Initialization
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Access_Initialization

procedure Main is
type A_Int is access Integer;
Expand All @@ -2485,7 +2485,7 @@ objects that have gone out of scope. For example:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Access_All
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Access_All

procedure Main is
type A_Int is access all Integer;
Expand All @@ -2497,7 +2497,7 @@ objects that have gone out of scope. For example:

[C]

.. code:: c run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Access_All_C
.. code:: c run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Access_All_C

!main.c
int main(int argc, const char * argv[])
Expand All @@ -2515,7 +2515,7 @@ the access type as follows:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Unchecked_Deallocation
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Unchecked_Deallocation

with Ada.Unchecked_Deallocation;

Expand All @@ -2529,7 +2529,7 @@ the access type as follows:

[C]

.. code:: c run_button project=Courses.Ada_For_C_Embedded_Dev.Perspective.Free
.. code:: c run_button project=Courses.Ada_For_Embedded_C_Dev.Perspective.Free

!main.c
#include <stdlib.h>
Expand Down Expand Up @@ -2656,7 +2656,7 @@ Here's a first example:
#include <stdio.h>
#include "proc.h"

void main (void)
int main(int argc, const char * argv[])
Copy link
Contributor

Choose a reason for hiding this comment

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

This has an int return type with no return statement.

{
int v1, v2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ using the Ravenscar profile. For example:

[Ada]

.. code:: ada compile_button project=Courses.Ada_For_C_Embedded_Dev.Concurrency.Ravenscar
.. code:: ada compile_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Ravenscar
:class: ada-expect-compile-error

package My_Tasks is
Expand Down Expand Up @@ -643,7 +643,7 @@ in the main application:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Concurrency.Ravenscar
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Ravenscar

with My_Tasks; use My_Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ assembler as well as source-level variables to be used for input and output:

[Ada]

.. code:: ada no_button project=Courses.Ada_For_C_Embedded_Dev.Embedded.Assembly_Code
.. code:: ada no_button project=Courses.Ada_For_Embedded_C_Dev.Embedded.Assembly_Code

with System.Machine_Code; use System.Machine_Code;
with Interfaces; use Interfaces;
Expand Down Expand Up @@ -350,7 +350,7 @@ obvious when looking at this code snippet:

[Ada]

.. code:: ada run_button project=Courses.Ada_For_C_Embedded_Dev.Embedded.Fixed_Point
.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Embedded.Fixed_Point

package Fixed_Definitions is

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ consider the following example in C:
[C]

.. code:: c manual_chop run_button project=Courses.Ada_For_Embedded_C_Dev.Performance.Division_By_Zero
:class: c-run-expect-failure

!main.c
#include <stdio.h>
Expand Down
11 changes: 3 additions & 8 deletions content/courses/intro-to-ada/chapters/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Arrays in Ada are used to define contiguous collections of elements that can be
selected by indexing. Here's a simple example:

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Greet
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -72,7 +71,6 @@ to index into the array.
equivalence between an array and a pointer to its initial element.

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Array_Bounds_Example
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -113,7 +111,6 @@ Since you can use any discrete type to index an array, enumeration types
are permitted.

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Month_Example
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -192,7 +189,7 @@ an element outside of the bounds of the array, you will get a run-time error
instead of accessing random memory as in unsafe languages.

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Greet_3
:class: ada-run, ada-run-expect-failure
:class: ada-run-expect-failure

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -317,7 +314,6 @@ in that case, the bounds will need to be provided when creating instances of
the type.

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Unconstrained_Array_Example
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -414,7 +410,6 @@ literals, as we can see in the example below.
end String_Literals;

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Greet_4
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand All @@ -439,7 +434,6 @@ type if you supply an initialization, since the bounds can be deduced from the
initialization expression.

.. code:: ada run_button project=Courses.Intro_To_Ada.Arrays.Greet_5
:class: ada-run

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -510,7 +504,8 @@ cases like this one, it is impossible for a compiler to know in the general
case if you are assigning a value of the correct length, so this violation will
generally result in a run-time error.

.. attention::
.. admonition:: Attention

While we will learn more about this later, it is important to know
that arrays are not the only types whose instances might be of unknown
size at compile-time.
Expand Down
4 changes: 2 additions & 2 deletions content/courses/intro-to-ada/chapters/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Ada exceptions are not types, but instead objects, which may be
peculiar to you if you're used to the way Java or Python support
exceptions. Here's how you declare an exception:

.. code:: ada no_button project=Courses.Intro_To_Ada.Exceptions.Show_Exception
.. code:: ada compile_button project=Courses.Intro_To_Ada.Exceptions.Show_Exception

package Exceptions is
My_Except : exception;
Expand Down Expand Up @@ -99,7 +99,7 @@ can add it to the statements block of your current subprogram:
Put ("Cannot open input file");
end Open_File;

.. attention::
.. admonition:: Attention

Exception handlers have an important restriction that
you need to be careful about: Exceptions raised in the declarative
Expand Down
8 changes: 4 additions & 4 deletions content/courses/intro-to-ada/chapters/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ by using the keyword :ada:`generic`. For example:
.. raph-amiard: We are lacking a definition/link of metaprogramming.


.. code:: ada no_button project=Courses.Intro_To_Ada.Generics.Show_Simple_Generic
.. code:: ada compile_button project=Courses.Intro_To_Ada.Generics.Show_Simple_Generic

generic
type T is private;
Expand All @@ -37,7 +37,7 @@ want to create an algorithm that works on any integer type, or even on
any type at all, whether a numeric type or not. The following example
declares a formal type :ada:`T` for the :ada:`Set` procedure.

.. code:: ada no_button project=Courses.Intro_To_Ada.Generics.Show_Formal_Type_Declaration
.. code:: ada compile_button project=Courses.Intro_To_Ada.Generics.Show_Formal_Type_Declaration

generic
type T is private;
Expand Down Expand Up @@ -71,7 +71,7 @@ Formal object declaration
Formal objects are similar to subprogram parameters. They can reference
formal types declared in the formal specification. For example:

.. code:: ada no_button project=Courses.Intro_To_Ada.Generics.Show_Formal_Object_Declaration
.. code:: ada compile_button project=Courses.Intro_To_Ada.Generics.Show_Formal_Object_Declaration

generic
type T is private;
Expand All @@ -95,7 +95,7 @@ We don't repeat the :ada:`generic` keyword for the body declaration of a
generic subprogram or package. Instead, we start with the actual
declaration and use the generic types and objects we declared. For example:

.. code:: ada no_button project=Courses.Intro_To_Ada.Generics.Show_Generic_Body_Definition
.. code:: ada compile_button project=Courses.Intro_To_Ada.Generics.Show_Generic_Body_Definition

generic
type T is private;
Expand Down
Loading