Giter Club home page Giter Club logo

learn's Introduction

learn.adacore.com

Sources for AdaCore's learn.adacore.com website


Typescript Test Suite Sphinx Plugin Tests Sphinx Content Tests

Requirements

This project requires Vagrant and VirtualBox

Getting started

To setup for development run:

$ vagrant up

This will spin up two VMs:

  • web: Is the build system for the frontend web content. This includes the webpack build system and sphinx build.

  • epub: Is the publishing server. This includes all packages needed to generate the learn website.

To build and start the development server for the frontend, run:

$ vagrant ssh web

# The following commands will be run inside the vm

$ source /vagrant/venv/bin/activate
$ cd /vagrant/frontend
$ yarn run dev

This will run webpack on the typescript and scss, then sphinx for the rst using make local which will point the widgets at 127.0.0.1:8000

You can then point your browser on your host to 127.0.0.1:8080 to see the learn website being served from vagrant.

To build and start the publishing server, run:

$ vagrant ssh epub

# The following commands will be run inside the VM

$ cd /vagrant
$ source venv/bin/activate
$ make site

This will build the content for the learn website. You can find it in the /vagrant/frontend/dist directory.

Testing the source-code examples

The ReST files found in the content directory have .. code:: ada blocks that contain source-code examples. To test the expected behavior of those examples, a test script called compile_blocks.py is available, as well as the code_projects module.

To make use of this test infrastructure, the best approach is to start the Vagrant publishing server (epub) and install the environment:

cd /vagrant/frontend
export PYTHONPATH="$PYTHONPATH:sphinx:py_modules"

Using the compile_blocks.py script

After the environment is set, running compile_blocks.py --help displays the help message:

python3 tests/compile_blocks.py --help

To test the code examples from a specific course, select the ReST files from that course and specify them as arguments to the compile_blocks.py script. For example, to test the Introduction to Ada course, run:

python3 tests/compile_blocks.py \
  $(find ../content/courses/intro-to-ada/ -name '*.rst')

Verbose mode

For more verbosity, just add the --verbose switch. For example:

python3 tests/compile_blocks.py \
  --verbose                     \
  $(find ../content/courses/intro-to-ada/ -name '*.rst')

Keep the build directory

To store the build files in a specific directory, just use the --build-dir switch and specify the directory. Also, use the --keep_files switch to prevent that directory from being deleted after the test is complete. For example:

python3 tests/compile_blocks.py \
  --keep_files                  \
  --build-dir test_output       \
  --verbose                     \
  $(find ../content/courses/intro-to-ada/ -name '*.rst')

Single ReST file

To test a single ReST file, specify just that file instead of multiple ReST files:

python3 tests/compile_blocks.py \
  ../content/index.rst

Single code block

To test just a single code block from the ReST file, use the --code-block-at switch:

python3 tests/compile_blocks.py \
  --code-block-at=28            \
  ../content/courses/intro-to-ada/chapters/imperative_language.rst

Maximum number of columns

To check whether a maximum limit of 80 columns per line is respected in the code examples, use the --max_columns switch:

python3 tests/compile_blocks.py \
  --max-columns 80              \
  ../content/index.rst

Using the code_projects module

The code_projects module contains the actual Python modules that are called by the compile_blocks.py script. It's possible to use them directly:

  • extract_projects.py extracts all code blocks and stores into the specified directory;

  • check_projects.py checks each code blocks from the specified directory.

For example, to build the source-code examples from the Introduction to Ada course, run:

python3 py_modules/code_projects/extract_projects.py     \
  --build-dir test_output                                \
  $(find ../content/courses/intro-to-ada/ -name '*.rst')

python3 py_modules/code_projects/check_projects.py       \
  --build-dir test_output

For more examples and alternative configurations, please refer to the README of the code_projects module

learn's People

Contributors

96radhikajadhav avatar aaronj1335 avatar clairedross avatar dependabot[bot] avatar dkm avatar dm-at-ada avatar fabien-chouteau avatar filip-gajowniczek-adacore avatar frank-at-adacore avatar franklinchen avatar gusthoff avatar jstuyts avatar kilian-gebhardt avatar manthonyaiello avatar marlonjames avatar opimedia avatar pat-rogers avatar pierretr avatar raph-amiard avatar rasheedja avatar reznikmm avatar richardkenner avatar robert-tice avatar rowan-walshe avatar serock avatar setton avatar spanners avatar timmyjose avatar tofgarion avatar yannickmoy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.