Skip to content

Commit cfe4a20

Browse files
authored
Adapt folder layout and finish pandoc integration (#69)
Completes the necessary folder layout rework and refactors pandoc file generation to work together with the rest of the tooling/setup. This finally finishes the pandoc integration to automatically generate teaching docs.
1 parent cdab539 commit cfe4a20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+573
-697
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
run: |
2121
tools/build/build \
2222
-d ${{runner.temp}}/output \
23-
-z ${{github.ref}} \
23+
-v ${GITHUB_REF#refs/*/} \
2424
-s
2525
############################################################

.github/workflows/ci_tool_tests.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This action is used to run tests to ensure all tools work like expected.
2+
3+
name: Tool CI
4+
5+
on: [push]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
matrix:
12+
python-version: [3.7, 3.8, 3.9]
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
pip install -r tools/requirements.txt
27+
28+
- name: Run unittests
29+
run: |
30+
cd tools
31+
pytest

.github/workflows/release.yml

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,60 +20,20 @@ jobs:
2020
shell: bash
2121
run: tools/build/prebuild
2222
############################################################
23+
- name: Collect git metadata
24+
id: git_metadata
25+
run: |
26+
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
2327
# The following builds the document in multiple formats for deployment.
2428
- name: Build the document.
2529
shell: bash
2630
run: |
2731
tools/build/build \
2832
-d ${{runner.temp}}/output \
29-
-z ${{github.ref}}
30-
############################################################
31-
# The following deploys to a different branch of the same repository
32-
# using an access token for authentication.
33-
# Note: It is recommended that this approach not be used.
34-
#- name: Deploy the built document to a GitHub Pages branch.
35-
# env:
36-
# DEPLOY_TOKEN: ${{secrets.DEPLOY_TOKEN}}
37-
# shell: bash
38-
# run: |
39-
# tools/build/deploy \
40-
# -f \
41-
# -m token \
42-
# -t ${{runner.temp}}/deploy_tmp \
43-
# -i ${{runner.temp}}/output \
44-
# -r mdadams/SG20 \
45-
# -b gh-pages \
46-
# -z ${{github.ref}}
47-
############################################################
48-
# The following deploys to a different branch of the same repository
49-
# using a deploy (i.e., SSH) key for authentication.
50-
- name: Deploy the built document to a GitHub Pages branch.
51-
env:
52-
DEPLOY_KEY: ${{secrets.DEPLOY_KEY}}
53-
shell: bash
54-
run: |
55-
tools/build/deploy \
56-
-f \
57-
-m key \
58-
-t ${{runner.temp}}/deploy_tmp \
59-
-i ${{runner.temp}}/output \
60-
-r mdadams/SG20 \
61-
-b gh-pages \
62-
-z ${{github.ref}}
63-
############################################################
64-
# The following deploys to a branch of a different repository
65-
# using a deploy (i.e., SSH) key authentication.
66-
- name: Deploy the built document to a GitHub Pages branch.
67-
env:
68-
DEPLOY_KEY: ${{secrets.ALT_DEPLOY_KEY}}
69-
shell: bash
70-
run: |
71-
tools/build/deploy \
72-
-f \
73-
-m key \
74-
-t ${{runner.temp}}/deploy_tmp_2 \
75-
-i ${{runner.temp}}/output \
76-
-r mdadams/sg20_guidelines_for_teaching_cpp \
77-
-b gh-pages \
78-
-z ${{github.ref}}
79-
############################################################
33+
-v ${{ steps.git_metadata.outputs.VERSION }}
34+
- name: Deploy generated content to gh-pages
35+
uses: peaceiris/actions-gh-pages@v3
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
publish_dir: ${{runner.temp}}/output
39+
keep_files: true

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
11
__pycache__/
2+
3+
# Ignore generated files
4+
sources/contributors.md
5+
sources/guidelines.epub
6+
sources/guidelines.html
7+
sources/guidelines.texi
8+
sources/guidelines_html/
9+
sources/knowledge_areas_summary.md
10+
sources/main.gen.md
11+
sources/main.pre.md
12+
sources/spellcheck_expected_sorted.txt
13+
sources/spellcheck_result.txt

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ This repository contains the source for the document:
88
When the repository is tagged, this document is automatically built
99
and made available via GitHub Pages at:
1010

11-
- <https://cplusplus.github.io/SG20/latest> (soon)
12-
- <https://mdadams.github.io/sg20_guidelines_for_teaching_cpp/latest>
13-
(currently)
14-
- <https://mdadams.github.io/SG20/latest> (currently)
11+
- <https://cplusplus.github.io/SG20/latest>
1512

1613
# Prerequisites for Building the Document
1714

TODO.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

config/spellcheck/ignored_words.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ expr
1010
Florian
1111
func
1212
Furst
13+
Hinnant
14+
html
1315
Hyland
1416
JC
1517
Krathwohl
@@ -21,7 +23,6 @@ Sattler
2123
SG
2224
Stroustrup
2325
udl
26+
Vandevoorde
2427
ver
2528
Winkel
26-
Hinnant
27-
Vandevoorde
Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
1-
# Module name: topic name
1+
## Module name: topic name
2+
23
_Skeleton descriptions are typeset in italic text,_
34
_so please don't remove these descriptions when editing the topic._
45

5-
## Overview
6+
### Overview
67

78
_Provides a short natural language abstract of the module’s contents._
89
_Specifies the different levels of teaching._
910

10-
<table>
11-
<thead>
12-
<th>Level</th>
13-
<th>Objectives</th>
14-
</thead>
15-
<tr>
16-
<td>Foundational</td>
17-
<td></td>
18-
</tr>
19-
<tr>
20-
<td>Main</td>
21-
<td></td>
22-
</tr>
23-
<tr>
24-
<td>Advanced</td>
25-
<td></td>
26-
</tr>
27-
</table>
28-
29-
## Motivation
11+
------------------------------------------------------------------------
12+
Level Objective
13+
----------------- ------------------------------------------------------
14+
Foundational ---
15+
16+
Main ---
17+
18+
Advanced ---
19+
20+
------------------------------------------------------------------------
21+
22+
### Motivation
3023

3124
_Why is this important?_
3225
_Why do we want to learn/teach this topic?_
3326

34-
## Topic introduction
27+
### Topic introduction
3528

3629
_Very brief introduction to the topic._
3730

38-
## Foundational: Using *
31+
### Foundational: Using *
3932

40-
### Background/Required Knowledge
33+
#### Background/Required Knowledge
4134

4235
A student:
4336

4437

45-
### Student outcomes
38+
#### Student outcomes
4639

4740
_A list of things "a student should be able to" after the curriculum._
4841
_The next word should be an action word and testable in an exam._
@@ -56,22 +49,22 @@ A student should be able to:
5649
4.
5750
5.
5851

59-
### Caveats
52+
#### Caveats
6053

6154
_This section mentions subtle points to understand, like anything resulting in
6255
implementation-defined, unspecified, or undefined behavior._
6356

64-
### Points to cover
57+
#### Points to cover
6558

6659
_This section lists important details for each point._
6760

68-
## Main: implementing *
61+
### Main: implementing *
6962

70-
### Background/Required Knowledge
63+
#### Background/Required Knowledge
7164

7265
* All of the above.
7366

74-
### Student outcomes
67+
#### Student outcomes
7568

7669
A student should be able to:
7770

@@ -81,11 +74,11 @@ A student should be able to:
8174
4.
8275
5.
8376

84-
### Caveats
77+
#### Caveats
8578

86-
### Points to cover
79+
#### Points to cover
8780

88-
## Advanced
81+
### Advanced
8982

9083
_These are important topics that are not expected to be covered but provide
9184
guidance where one can continue to investigate this topic in more depth._

sources/Makefile

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ DOC_SPELLCHECK_MUST_PASS = 1
1515
INSTALL_DIR = $(TOP_DIR)/install
1616

1717
# All of the Markdown source files (that are not generated during build).
18-
SOURCES = \
19-
modules/compile-time-programming/requires-expressions.md \
20-
modules/functions/defaulted-parameters.md \
21-
modules/functions/user-defined-literals.md \
22-
modules/object-model/copy-semantics.md \
23-
course_examples.md \
24-
disclaimer.md \
25-
glossary.md \
18+
SOURCES = $(shell find . -mindepth 2 -name '*.md')
19+
20+
# Special top-level markdown files
21+
EXTRA_SOURCES = glossary.md \
2622
contributing.md \
2723
introduction.md \
28-
main.md \
24+
main_raw.md \
2925
obtaining_document.md \
3026
references.md \
3127

3228
# The Markdown files that are generated during the build process.
3329
GENERATED_MARKDOWN = \
3430
knowledge_areas_summary.md \
31+
main.pre.md \
3532
main.gen.md \
3633
contributors.md \
3734

35+
# Merge extra sources with detected sources for teaching modules
36+
SOURCES += $(EXTRA_SOURCES)
37+
3838
################################################################################
3939
# Define primary targets.
4040
################################################################################
@@ -96,6 +96,7 @@ install: all
9696
# Some additional configuration.
9797
################################################################################
9898

99+
MAIN_GENERATOR= $(TOP_DIR)/tools/build/generate_main.py
99100
MD_PREPROCESSOR = $(TOP_DIR)/tools/build/preprocessor
100101
MAKE_MARKDOWN = $(TOP_DIR)/tools/build/make_markdown
101102
SPELLCHECK_DIR = $(TOP_DIR)/config/spellcheck
@@ -104,14 +105,17 @@ SPELLCHECK_DIR = $(TOP_DIR)/config/spellcheck
104105
# Preprocessing setup.
105106
################################################################################
106107

107-
main.gen.md: $(SOURCES) contributors.md main.md
108-
$(MD_PREPROCESSOR) -v $(DOC_VERSION) < main.md > main.gen.md
108+
main.pre.md: $(SOURCES) contributors.md main_raw.md
109+
$(MAIN_GENERATOR) --raw main_raw.md --out main.pre.md --module-folder modules
110+
111+
main.gen.md: $(SOURCES) contributors.md main.pre.md
112+
$(MD_PREPROCESSOR) -v $(DOC_VERSION) < main.pre.md > main.gen.md
109113

110114
knowledge_areas_summary.md: $(SOURCES) knowledge_areas.dat
111115
$(MAKE_MARKDOWN) < knowledge_areas.dat > knowledge_areas_summary.md
112116

113117
contributors.md:
114-
git log --all --pretty="%an" | sort | uniq > contributors.md
118+
git log --all --pretty="%aN" | sort | uniq > contributors.md
115119

116120
################################################################################
117121
# Establish Pandoc settings.
@@ -163,21 +167,16 @@ guidelines.tex:
163167

164168
spellcheck_result.txt: guidelines.html
165169
rm -f $@
166-
rm -f spellcheck_expected_sorted.txt
167-
sort $(SPELLCHECK_DIR)/ignored_words.txt | \
168-
uniq > spellcheck_expected_sorted.txt
169170
PATH="$(TOP_DIR)/tools/build:$$PATH" pandoc --from $(INPUT_FORMAT) \
170171
--lua-filter $(TOP_DIR)/tools/pandoc_filters/spellcheck.lua \
171172
main.gen.md | sort | uniq > $@
172-
@status=0; \
173-
diff -q spellcheck_expected_sorted.txt $@ || \
174-
status=1; \
175-
if [ $$status -ne 0 ]; then \
176-
echo "SPELLING ERRORS DETECTED:"; \
177-
diff -u spellcheck_expected_sorted.txt $@ | \
178-
grep '^[+-]'; \
173+
if [ -s $@ ]; then \
174+
echo "DETECTED SPELLING ERRORS:"; \
175+
cat $@ | while read line; do echo "Misspelled '$$line' in:"; \
176+
grep -R "$$line" -n --color=auto --include='*.md' --exclude='main.gen.md'; done; \
177+
sync; \
179178
if [ $(DOC_SPELLCHECK_MUST_PASS) -ne 0 ]; then \
180-
echo "ERROR: spelling errors detected"; \
179+
echo "ERROR: spelling errors detected, cannot proceed!"; \
181180
exit 1; \
182181
else \
183182
echo "WARNING: spelling errors detected"; \

sources/course_examples.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

sources/disclaimer.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

sources/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<head>
2-
<meta http-equiv="refresh" content="0; URL=https://mdadams.github.io/sg20_guidelines_for_teaching_cpp/latest/" />
2+
<meta http-equiv="refresh" content="0; URL=https://cplusplus.github.io/SG20/latest/" />
33
</head>
4+
45
<body>
5-
<p>If you are not redirected in five seconds, <a href="https://mdadams.github.io/sg20_guidelines_for_teaching_cpp/latest/">click here</a>.</p>
6+
<p>If you are not redirected in five seconds, <a href="https://cplusplus.github.io/SG20/latest/">click here</a>.</p>
67
</body>

0 commit comments

Comments
 (0)