From 1d32319046085f4d3e7c663e25de8c8e19749bb5 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Thu, 5 Nov 2020 11:10:40 +0100 Subject: [PATCH 01/30] add image-with-shadow class --- assets/css/lesson.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index 182fe3b7..bf345243 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -299,6 +299,10 @@ span.fold-unfold { } +img.image-with-shadow { + box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 24px 0 rgba(0, 0, 0, 0.19); +} + //---------------------------------------- // Life cycle box //---------------------------------------- From d021e1fc38e38ee9d2b6ad298831aa8d519454a0 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 10 Feb 2021 01:14:24 -0800 Subject: [PATCH 02/30] add patch to clean gh-pages before committing (#545) This will address #544 --- .github/workflows/website.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index fc08b084..cb67828c 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -97,6 +97,11 @@ jobs: - name: Commit and Push if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}} run: | + # clean up gh-pages + cd gh-pages + git rm -rf . # remove all previous files + git restore --staged . # remove things from the stage + cd .. # copy everything into gh-pages site cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages # move into gh-pages, add, commit, and push @@ -105,7 +110,7 @@ jobs: git config --local user.email "actions@github.com" git config --local user.name "GitHub Actions" git add -A . - git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }}" + git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})" git push origin gh-pages # return cd .. From f419f9cdc6945caef5c8881301ea73c8cc6c7ac9 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 15 Feb 2021 14:36:29 -0600 Subject: [PATCH 03/30] Fix Kramdown parser crash ... by using GFM (GitHub-flavored Markdown) parser (`kramdown-parser-gfm`) instead of the default one (`kramdown`). The default one fails to produce an AST (Abstract Syntax Tree) when there is no blank line before the line with the opening code fence. Related: - gettalong/kramdown#530 - Python-Markdown/markdown#807 Fixes: carpentries/styles#543 --- .github/workflows/template.yml | 2 +- .github/workflows/website.yml | 2 +- bin/markdown_ast.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml index 84015e4d..c1e52b1b 100644 --- a/.github/workflows/template.yml +++ b/.github/workflows/template.yml @@ -44,7 +44,7 @@ jobs: - name: Install GitHub Pages, Bundler, and kramdown gems run: | - gem install github-pages bundler kramdown + gem install github-pages bundler kramdown kramdown-parser-gfm - name: Install Python modules run: | diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index cb67828c..df79f6c5 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -28,7 +28,7 @@ jobs: - name: Install GitHub Pages, Bundler, and kramdown gems run: | - gem install github-pages bundler kramdown + gem install github-pages bundler kramdown kramdown-parser-gfm - name: Install Python modules run: | diff --git a/bin/markdown_ast.rb b/bin/markdown_ast.rb index 4fdb6843..2ef3f772 100755 --- a/bin/markdown_ast.rb +++ b/bin/markdown_ast.rb @@ -4,9 +4,10 @@ # Use Kramdown parser to produce AST for Markdown document. require 'kramdown' +require 'kramdown-parser-gfm' require 'json' markdown = $stdin.read -doc = Kramdown::Document.new(markdown) +doc = Kramdown::Document.new(markdown, input: 'GFM', hard_wrap: false) tree = doc.to_hash_a_s_t puts JSON.pretty_generate(tree) From 2a550c74082ccb5e49d1e344c29706c834a44bde Mon Sep 17 00:00:00 2001 From: Andrew Reid Date: Mon, 22 Feb 2021 02:31:24 -0500 Subject: [PATCH 04/30] bin/util.py: Change ruby executable to "bundle exec ruby" Closes: carpentries/styles#547 --- bin/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/util.py b/bin/util.py index 0e16d869..f3378f6b 100644 --- a/bin/util.py +++ b/bin/util.py @@ -115,7 +115,7 @@ def read_markdown(parser, path): for (i, line) in enumerate(body.split('\n'))] # Parse Markdown. - cmd = 'ruby {0}'.format(parser) + cmd = 'bundle exec ruby {0}'.format(parser) p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True, universal_newlines=True, encoding='utf-8') stdout_data, stderr_data = p.communicate(body) From a4e53f948f2572934c64d8b70a654ca6bea814bb Mon Sep 17 00:00:00 2001 From: Bailey Harrington Date: Mon, 22 Feb 2021 13:51:58 +0000 Subject: [PATCH 05/30] Change link colours (#549) ...to make them distinguishable from regular text. And for accessibility! --- assets/css/lesson.scss | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index 9ecd5452..806315de 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -210,6 +210,20 @@ a code { color: #006cad; } +a:link { + color: #196EBD; +} + +a:active, +a:hover { + outline: 0; + text-decoration: underline; +} + +a:visited { + color: #1AA4DA; +} + code { white-space: nowrap; padding: 2px 5px; From 03fb1a0ffeb998d6921e4c0b00aa887f52b853e6 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Thu, 4 Mar 2021 17:54:53 +0100 Subject: [PATCH 06/30] bin/workshop_check.py: update default contact email address --- bin/workshop_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/workshop_check.py b/bin/workshop_check.py index 15d954a6..2c8dddf3 100644 --- a/bin/workshop_check.py +++ b/bin/workshop_check.py @@ -17,7 +17,7 @@ # Defaults. CARPENTRIES = ("dc", "swc", "lc", "cp") -DEFAULT_CONTACT_EMAIL = 'admin@software-carpentry.org' +DEFAULT_CONTACT_EMAIL = 'team@carpentries.org' USAGE = 'Usage: "workshop_check.py path/to/root/directory"' From a841a56c896554249ac2d8566d630080defe72b1 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Fri, 5 Mar 2021 11:28:26 -0500 Subject: [PATCH 07/30] Gemfile: add 'webrick' dependency for Ruby 3.0.0 and above Fixes carpentries/styles#552 --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 41c97a9a..8d69492b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } ruby '>=2.7.1' gem 'github-pages', group: :jekyll_plugins + +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') + gem 'webrick', '>= 1.6.1' +end \ No newline at end of file From 32f7bd1e80eda16ba33bdebb1fe0ad5896a606e8 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 10 Mar 2021 10:21:57 -0800 Subject: [PATCH 08/30] lesson_check.py allow for missing life_cycle This will fix https://github.com/carpentries/styles/issues/556 --- bin/lesson_check.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 25388d39..889596c2 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -188,7 +188,10 @@ def check_config(reporter, source_dir): reporter.check(defaults in config.get('defaults', []), 'configuration', '"root" not set to "." in configuration') - return config['life_cycle'] + if 'life_cycle' in config: + return config['life_cycle'] + else + return None def check_source_rmd(reporter, source_dir, parser): """Check that Rmd episode files include `source: Rmd`""" From b2f42c2ed2b9aafcb312bab9ca21fd1701984c5a Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 10 Mar 2021 11:12:58 -0800 Subject: [PATCH 09/30] update with Maxim's suggestion --- bin/lesson_check.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 889596c2..193f994f 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -188,10 +188,9 @@ def check_config(reporter, source_dir): reporter.check(defaults in config.get('defaults', []), 'configuration', '"root" not set to "." in configuration') - if 'life_cycle' in config: - return config['life_cycle'] - else - return None + if 'life_cycle' not in config: + config['life_cycle'] = None + return config['life_cycle'] def check_source_rmd(reporter, source_dir, parser): """Check that Rmd episode files include `source: Rmd`""" From 0554a8d099cbc999121e36d59f402ea90fa20269 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Thu, 11 Mar 2021 09:08:08 -0800 Subject: [PATCH 10/30] Add catch for None type code block in lesson_check There are times when the AST is malformed and does not emit a class for the code element. We do not want the parser to crash when this happens, but we also want to notify ourselves that the AST is malformed. This should not result in an error because as we saw in https://github.com/carpentries/styles/issues/543, the parser itself can cause these malformations when the lesson itself renders well. Even though we fixed the previous issue with an updated parser, problems still persist: https://github.com/swcarpentry/r-novice-gapminder/pull/696#issuecomment-796265728 I fully admit that this is a kludge. --- bin/lesson_check.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 193f994f..4aa1eec9 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -392,10 +392,14 @@ def check_codeblock_classes(self): for node in self.find_all(self.doc, {'type': 'codeblock'}): cls = self.get_val(node, 'attr', 'class') - self.reporter.check(cls in KNOWN_CODEBLOCKS or cls.startswith('language-'), + self.reporter.check(cls is not none and (cls in KNOWN_CODEBLOCKS or + cls.startswith('language-')), (self.filename, self.get_loc(node)), 'Unknown or missing code block type {0}', cls) + if not cls is None: + print("NOTE: The AST was malformed and needs to be investigated") + print(self.filename, self.get_loc(node)) def check_defined_link_references(self): """Check that defined links resolve in the file. From cce6a66f4b0273f703730e9729592a2dcc45f645 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Thu, 11 Mar 2021 09:32:54 -0800 Subject: [PATCH 11/30] fix syntax I've removed the print condition, because it will just result in an error no matter what (sigh) --- bin/lesson_check.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 4aa1eec9..74d50549 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -392,14 +392,11 @@ def check_codeblock_classes(self): for node in self.find_all(self.doc, {'type': 'codeblock'}): cls = self.get_val(node, 'attr', 'class') - self.reporter.check(cls is not none and (cls in KNOWN_CODEBLOCKS or + self.reporter.check(cls is not None and (cls in KNOWN_CODEBLOCKS or cls.startswith('language-')), (self.filename, self.get_loc(node)), 'Unknown or missing code block type {0}', cls) - if not cls is None: - print("NOTE: The AST was malformed and needs to be investigated") - print(self.filename, self.get_loc(node)) def check_defined_link_references(self): """Check that defined links resolve in the file. From 905d24a8644df9c626a02f639423146e472a96a3 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 16 Mar 2021 13:58:05 -0500 Subject: [PATCH 12/30] Makefile: fix 'bundle config' command flags --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 60bd888b..934041b6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Settings MAKEFILES=Makefile $(wildcard *.mk) -JEKYLL=bundle config --local set path .vendor/bundle && bundle install && bundle update && bundle exec jekyll +JEKYLL=bundle config set --local path .vendor/bundle && bundle install && bundle update && bundle exec jekyll PARSER=bin/markdown_ast.rb DST=_site From b43257a1439e31a26d1a2ec63fffdd489c194f77 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 18 Mar 2021 17:13:38 -0500 Subject: [PATCH 13/30] Makefile: clean target: remove .vendor, .bundle, Gemfile.lock Clean up: 1. `.vendor` directory where Bundler installs all the gems. 2. `.bundle` directory where Bundler stores its settings. 3. `Gemfile.lock` file generated by the Bundler. --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 934041b6..30c2b202 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,9 @@ clean : @rm -rf ${DST} @rm -rf .sass-cache @rm -rf bin/__pycache__ + @rm -rf .vendor + @rm -rf .bundle + @rm -f Gemfile.lock @find . -name .DS_Store -exec rm {} \; @find . -name '*~' -exec rm {} \; @find . -name '*.pyc' -exec rm {} \; From 39a32f6289cce93f1711a1a454b11b5eb66b1861 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 18 Mar 2021 17:17:56 -0500 Subject: [PATCH 14/30] Makefile: silence Docker commands --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 30c2b202..d0be0d18 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,8 @@ site : lesson-md ## * docker-serve : use Docker to serve the site docker-serve : - docker pull carpentries/lesson-docker:latest - docker run --rm -it \ + @docker pull carpentries/lesson-docker:latest + @docker run --rm -it \ -v $${PWD}:/home/rstudio \ -p 4000:4000 \ -p 8787:8787 \ From ed77edaea17ac700970da9388d489256d5e3494e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Fri, 19 Mar 2021 15:26:24 +0100 Subject: [PATCH 15/30] use Ruby's official GH Actions --- .github/workflows/template.yml | 3 ++- .github/workflows/website.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml index c1e52b1b..810bf2d2 100644 --- a/.github/workflows/template.yml +++ b/.github/workflows/template.yml @@ -33,9 +33,10 @@ jobs: RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest' steps: - name: Set up Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' + bundler-cache: true - name: Set up Python uses: actions/setup-python@v2 diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index df79f6c5..af3519fe 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -17,9 +17,10 @@ jobs: shell: bash steps: - name: Set up Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '2.7' + bundler-cache: true - name: Set up Python uses: actions/setup-python@v2 From b46187f7ec0b7cf2cd26ba12509c10e0b2e4bcf6 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 19 Mar 2021 10:20:04 -0500 Subject: [PATCH 16/30] Makefile: use SHELL to call bin/knit_lesson.sh --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d0be0d18..befd7b28 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ lesson-md : ${RMD_DST} _episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps @mkdir -p _episodes - @bin/knit_lessons.sh $< $@ + @$(SHELL) bin/knit_lessons.sh $< $@ ## * lesson-check : validate lesson Markdown lesson-check : lesson-fixme From b1ca20a2b2cb65adf101e0a6912c39c10fda17c9 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 19 Mar 2021 10:29:26 -0500 Subject: [PATCH 17/30] Makefile: fix up PHONY targets --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index befd7b28..9d952810 100644 --- a/Makefile +++ b/Makefile @@ -31,15 +31,14 @@ ifeq (,$(PYTHON)) endif -# Controls -.PHONY : commands clean files - # Default target .DEFAULT_GOAL := commands ## I. Commands for both workshop and lesson websites ## ================================================= +.PHONY: site docker-serve repo-check clean clean-rmd + ## * serve : render website and run a local server serve : lesson-md ${JEKYLL} serve @@ -160,6 +159,8 @@ lesson-fixme : ## IV. Auxililary (plumbing) commands ## ================================================= +.PHONY : commands + ## * commands : show all commands. commands : @sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST) From 943c8d9968f7a9170924513e4e7d4f0a6bf9d0d5 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 19 Mar 2021 14:28:40 -0500 Subject: [PATCH 18/30] Fix GitHub actions for lessons in Rmarkdown Specifically, set CRAN repository to https://cran.rstudio.com --- .github/workflows/template.yml | 3 ++- .github/workflows/website.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml index 810bf2d2..9d7f3b48 100644 --- a/.github/workflows/template.yml +++ b/.github/workflows/template.yml @@ -97,7 +97,8 @@ jobs: - name: Install needed packages if: steps.check-rmd.outputs.count != 0 run: | - install.packages(setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))) + packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages())) + install.packages(packages, repo="https://cran.rstudio.com/") shell: Rscript {0} - name: Query dependencies diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index af3519fe..246d4c70 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -63,7 +63,8 @@ jobs: - name: Install needed packages if: steps.check-rmd.outputs.count != 0 run: | - install.packages(setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))) + packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages())) + install.packages(packages, repo="https://cran.rstudio.com/") shell: Rscript {0} - name: Query dependencies From 4df32a87f2d4ca683b3624e1672c53f1cef10e26 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Mon, 22 Mar 2021 11:37:48 +0100 Subject: [PATCH 19/30] apply single shadow to image class --- assets/css/lesson.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index e5908712..973a67ab 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -302,7 +302,7 @@ span.fold-unfold { img.image-with-shadow { - box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 24px 0 rgba(0, 0, 0, 0.19); + box-shadow: 0 6px 24px 0 rgba(0, 0, 0, 0.25); } //---------------------------------------- From 93dfc15b561af3da2c43f378fde19d7720cf4027 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Mon, 22 Mar 2021 11:40:54 +0100 Subject: [PATCH 20/30] use grey shadow instead of transparent black --- assets/css/lesson.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index 973a67ab..bd31caa0 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -302,7 +302,7 @@ span.fold-unfold { img.image-with-shadow { - box-shadow: 0 6px 24px 0 rgba(0, 0, 0, 0.25); + box-shadow: 0 6px 24px 0 #888; } //---------------------------------------- From 4b2036879c88f68e420f101c1cc1c29d2d300ffc Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Tue, 23 Mar 2021 14:44:23 +0100 Subject: [PATCH 21/30] expand image-with-shadow selection --- assets/css/lesson.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index bd31caa0..fe174ab8 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -301,6 +301,7 @@ span.fold-unfold { } +p.image-with-shadow img, img.image-with-shadow { box-shadow: 0 6px 24px 0 #888; } From 5a010aba8c26166e8d556945d35901ff391b3763 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 23 Mar 2021 09:15:33 -0500 Subject: [PATCH 22/30] Makefile: don't fail when Python isn't found --- Makefile | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 9d952810..8b02ab11 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DST=_site PYTHON3_EXE := $(shell which python3 2>/dev/null) ifneq (, $(PYTHON3_EXE)) ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE)))) - PYTHON := python3 + PYTHON := $(PYTHON3_EXE) endif endif @@ -21,12 +21,13 @@ ifeq (,$(PYTHON)) ifneq (, $(PYTHON_EXE)) PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) - ifneq (3, ${PYTHON_VERSION_MAJOR}) - $(error "Your system does not appear to have Python 3 installed.") + ifeq (3, ${PYTHON_VERSION_MAJOR}) + PYTHON := $(PYTHON_EXE) + else + PYTHON_NOTE = "Your system does not appear to have Python 3 installed." endif - PYTHON := python else - $(error "Your system does not appear to have any Python installed.") + PYTHON_NOTE = "Your system does not appear to have any Python installed." endif endif @@ -59,7 +60,7 @@ docker-serve : carpentries/lesson-docker:latest ## * repo-check : check repository settings -repo-check : +repo-check : python @${PYTHON} bin/repo_check.py -s . ## * clean : clean up junk files @@ -87,7 +88,7 @@ clean-rmd : .PHONY : workshop-check ## * workshop-check : check workshop homepage -workshop-check : +workshop-check : python @${PYTHON} bin/workshop_check.py . @@ -133,15 +134,15 @@ _episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps @$(SHELL) bin/knit_lessons.sh $< $@ ## * lesson-check : validate lesson Markdown -lesson-check : lesson-fixme +lesson-check : python lesson-fixme @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md ## * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace -lesson-check-all : +lesson-check-all : python @${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive ## * unittest : run unit tests on checking tools -unittest : +unittest : python @${PYTHON} bin/test_lesson_check.py ## * lesson-files : show expected names of generated files for debugging @@ -159,8 +160,15 @@ lesson-fixme : ## IV. Auxililary (plumbing) commands ## ================================================= -.PHONY : commands +.PHONY : commands python ## * commands : show all commands. commands : @sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST) + +python : +ifeq (, $(PYTHON)) + $(error $(PYTHON_NOTE)) +else + @: +endif From 1bad008530933b2b15afefd0631f258c2c3e1b8a Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Sat, 27 Mar 2021 13:20:29 -0500 Subject: [PATCH 23/30] bin/dependencies.R: handle 'no packages were specified' error Fixes the following issue: ``` $ make site lib paths: /Library/Frameworks/R.framework/Versions/3.5/Resources/library Error in install.packages(missing_pkgs, lib = lib, repos = repos) : no packages were specified Calls: install_required_packages -> install.packages Execution halted make: *** [install-rmd-deps] Error 1 ``` --- bin/dependencies.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/dependencies.R b/bin/dependencies.R index 640b3e24..ee9d38a8 100644 --- a/bin/dependencies.R +++ b/bin/dependencies.R @@ -5,10 +5,10 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def } message("lib paths: ", paste(lib, collapse = ", ")) - missing_pkgs <- setdiff( - c("rprojroot", "desc", "remotes", "renv"), - rownames(installed.packages(lib.loc = lib)) - ) + required_pkgs <- c("rprojroot", "desc", "remotes", "renv") + installed_pkgs <- rownames(installed.packages(lib.loc = lib)) + missing_pkgs <- setdiff(required_pkgs, installed_pkgs) + # The default installation of R will have "@CRAN@" as the default repository, which directs contrib.url() to either # force the user to choose a mirror if interactive or fail if not. Since we are not interactve, we need to force the # mirror here. @@ -16,8 +16,9 @@ install_required_packages <- function(lib = NULL, repos = getOption("repos", def repos <- c(CRAN = "https://cran.rstudio.com/") } - install.packages(missing_pkgs, lib = lib, repos = repos) - + if (length(missing_pkgs) != 0) { + install.packages(missing_pkgs, lib = lib, repos = repos) + } } find_root <- function() { From 4df505249a27191c3475102cde4c150b0a131102 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 14 Apr 2021 00:42:49 -0500 Subject: [PATCH 24/30] Don't check links.md in lessons that use remote theme Fixes carpentries/styles#570 --- bin/lesson_check.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 74d50549..249464fd 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -113,7 +113,10 @@ def main(): if life_cycle == "pre-alpha": args.permissive = True check_source_rmd(args.reporter, args.source_dir, args.parser) - args.references = read_references(args.reporter, args.reference_path) + + args.references = {} + if not using_remote_theme(): + args.references = read_references(args.reporter, args.reference_path) docs = read_all_markdown(args.source_dir, args.parser) check_fileset(args.source_dir, args.reporter, list(docs.keys())) @@ -167,6 +170,10 @@ def parse_args(): return args +def using_remote_theme(): + config_file = os.path.join(source_dir, '_config.yml') + config = load_yaml(config_file) + return 'remote_theme' in config def check_config(reporter, source_dir): """Check configuration file.""" @@ -493,7 +500,8 @@ def check(self): """Run extra tests.""" super().check() - self.check_reference_inclusion() + if not using_remote_theme(): + self.check_reference_inclusion() def check_metadata(self): super().check_metadata() From 9a73007fcaa85d62dbcfe399acb9de29da4d33f4 Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Wed, 14 Apr 2021 21:25:35 +0200 Subject: [PATCH 25/30] add link references to code_of_conduct.md (#572) --- CODE_OF_CONDUCT.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c3b96690..2cf1133b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,4 +8,5 @@ we pledge to follow the [Carpentry Code of Conduct][coc]. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by following our [reporting guidelines][coc-reporting]. -{% include links.md %} +[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html +[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html From ced22447d6a8f97bc26d7eb5af166392d1e4e902 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Thu, 15 Apr 2021 01:08:10 +0100 Subject: [PATCH 26/30] Update links.md --- _includes/links.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/links.md b/_includes/links.md index abe60930..7f8e0026 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -12,7 +12,7 @@ [cran-stringr]: https://cran.r-project.org/package=stringr [dc-lessons]: http://www.datacarpentry.org/lessons/ [email]: mailto:team@carpentries.org -[github-importer]: https://import.github.com/ +[github-importer]: https://import2.github.com/ [importer]: https://github.com/new/import [jekyll-collection]: https://jekyllrb.com/docs/collections/ [jekyll-install]: https://jekyllrb.com/docs/installation/ From 494e2d60064578d1e5a45df0734ef9b8865c3e29 Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar" Date: Wed, 14 Apr 2021 17:38:35 -0700 Subject: [PATCH 27/30] add source_dir argument This will fix https://github.com/carpentries/styles/issues/576 --- bin/lesson_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 249464fd..cb38e5b2 100644 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -115,7 +115,7 @@ def main(): check_source_rmd(args.reporter, args.source_dir, args.parser) args.references = {} - if not using_remote_theme(): + if not using_remote_theme(args.source_dir): args.references = read_references(args.reporter, args.reference_path) docs = read_all_markdown(args.source_dir, args.parser) @@ -170,7 +170,7 @@ def parse_args(): return args -def using_remote_theme(): +def using_remote_theme(source_dir): config_file = os.path.join(source_dir, '_config.yml') config = load_yaml(config_file) return 'remote_theme' in config From 01fa7e60d9672aacc405121bdacf835e10ae723c Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Apr 2021 13:22:09 -0500 Subject: [PATCH 28/30] Improved relative_root_path --- _includes/base_path.html | 54 +++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/_includes/base_path.html b/_includes/base_path.html index 7efb3570..41139587 100644 --- a/_includes/base_path.html +++ b/_includes/base_path.html @@ -1,27 +1,41 @@ -{% comment %} -This is adapted from: https://ricostacruz.com/til/relative-paths-in-jekyll +{%- comment -%} +When the website is built by GitHub Pages, +'site.url' is set to 'https://username.github.io' +'site.baseurl' is set to '/lesson-name' -`page.url` gives the URL of the current page with a leading /: +When we start a local server using `jekyll serve`, +'site.url' is set to 'http://localhost:4000' and +'site.baseurl' is empty. -- when the URL ends with the extension (e.g., /foo/bar.html) then we can get - the depth by counting the number of / and remove - 1 -- when the URL ends with a / (e.g. /foo/bar/) then the number / gives the depth - directly -{% endcomment %} +In both of the above cases we set 'relative_root_path' to 'site.url + site.baseurl'. -{% assign relative_root_path = '' %} +When we build a website locally with `jekyll build`, +both 'site.url' and 'site.baseurl' are empty. +This case is handled by the last 'else' in the code below. +The logic there follows the (adapted) instructions found at: + https://ricostacruz.com/til/relative-paths-in-jekyll -{% assign last_char = page.url | slice: -1 %} + `page.url` gives the URL of the current page with a leading /: -{% if last_char == "/"} -{% assign offset = 0 %} -{% else %} -{% assign offset = 1 %} -{% endif %} + - when the URL ends with an extension (e.g., /foo/bar.html), + we can get the 'depth' of the page by counting the number of + forward slashes ('/') and subtracting 1 + - when the URL ends with a forward slash (e.g. /foo/bar/), + we can get the depth of the page by counting the number of / +{%- endcomment -%} -{% assign depth = page.url | split: '/' | size | minus: offset %} -{% if depth <= 1 %}{% assign relative_root_path = '.' %} -{% elsif depth == 2 %}{% assign relative_root_path = '..' %} -{% elsif depth == 3 %}{% assign relative_root_path = '../..' %} -{% elsif depth == 4 %}{% assign relative_root_path = '../../..' %} +{% if site.url %} + {% assign relative_root_path = site.url | append: site.baseurl %} +{% else %} + {% assign last_char = page.url | slice: -1 %} + {% if last_char == "/" %} + {% assign offset = 0 %} + {% else %} + {% assign offset = 1 %} + {% endif %} + {% assign depth = page.url | split: '/' | size | minus: offset %} + {% if depth <= 1 %}{% assign relative_root_path = '.' %} + {% elsif depth == 2 %}{% assign relative_root_path = '..' %} + {% else %}{% capture relative_root_path %}..{% for i in (3..depth) %}/..{% endfor %}{% endcapture %} + {% endif %} {% endif %} From 8541f28df500c8cf546bbf8455bc26bf829ddd2d Mon Sep 17 00:00:00 2001 From: Toby Hodges Date: Sat, 17 Apr 2021 02:13:35 +0200 Subject: [PATCH 29/30] update contributing guide --- bin/boilerplate/CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/boilerplate/CONTRIBUTING.md b/bin/boilerplate/CONTRIBUTING.md index f5158b02..a997b350 100644 --- a/bin/boilerplate/CONTRIBUTING.md +++ b/bin/boilerplate/CONTRIBUTING.md @@ -70,7 +70,7 @@ There are many ways to contribute, from writing new exercises and improving existing ones to updating or filling in the documentation and submitting [bug reports][issues] -about things that do not work, aren not clear, or are missing. +about things that do not work, are not clear, or are missing. If you are looking for ideas, please see the 'Issues' tab for a list of issues associated with this repository, or you may also look at the issues for [Data Carpentry][dc-issues], @@ -94,7 +94,7 @@ and (b) explain what you would take out to make room for it. The first encourages contributors to be honest about requirements; the second, to think hard about priorities. -We are also not looking for exercises or other material that only run on one platform. +We are also not looking for exercises or other material that will only run on one platform. Our workshops typically contain a mixture of Windows, macOS, and Linux users; in order to be usable, our lessons must run equally well on all three. @@ -104,7 +104,7 @@ our lessons must run equally well on all three. If you choose to contribute via GitHub, you may want to look at [How to Contribute to an Open Source Project on GitHub][how-contribute]. To manage changes, we follow [GitHub flow][github-flow]. -Each lesson has two maintainers who review issues and pull requests or encourage others to do so. +Each lesson has at least two maintainers who review issues and pull requests or encourage others to do so. The maintainers are community volunteers and have final say over what gets merged into the lesson. To use the web interface for contributing to a lesson: @@ -128,12 +128,12 @@ repository for reference while revising. ## Other Resources -General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site] +General discussion of [Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site] happens on the [discussion mailing list][discuss-list], which everyone is welcome to join. You can also [reach us by email][email]. -[email]: mailto:admin@software-carpentry.org +[email]: mailto:team@carpentries.org [dc-issues]: https://github.com/issues?q=user%3Adatacarpentry [dc-lessons]: http://datacarpentry.org/lessons/ [dc-site]: http://datacarpentry.org/ From a56a34e029802273f715990da258e3cc750b6588 Mon Sep 17 00:00:00 2001 From: Benson Muite Date: Tue, 20 Apr 2021 18:44:22 +0300 Subject: [PATCH 30/30] add further languages for box titles (#580) Will be useful for HPC-Carpentry lessons, GPU programming lesson as well as Julia lessons which are currently in the incubator. --- assets/css/lesson.scss | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/assets/css/lesson.scss b/assets/css/lesson.scss index fe174ab8..68a35508 100644 --- a/assets/css/lesson.scss +++ b/assets/css/lesson.scss @@ -64,16 +64,32 @@ div.error::before { background-color: #ffebe6; content: "Error"; } div.warning:before { background-color: #f8f4e8; content:" Warning"; } div.output::before { background-color: #efefef; content: "Output"; } -div.language-bash::before { content: "Bash"; } -div.language-c::before { content: "C"; } -div.language-cmake::before { content: "CMake"; } -div.language-cpp::before { content: "C++"; } -div.language-html::before { content: "HTML"; } -div.language-make::before { content: "Make"; } -div.language-matlab::before { content: "MATLAB"; } -div.language-python::before { content: "Python"; } -div.language-r::before { content: "R"; } -div.language-sql::before { content: "SQL"; } +div.language-basic::before { content: "Basic"; } +div.language-bash::before { content: "Bash"; } +div.language-c::before { content: "C"; } +div.language-chapel::before { content: "Chapel"; } +div.language-cmake::before { content: "CMake"; } +div.language-cpp::before { content: "C++"; } +div.language-cuda::before { content: "Cuda"; } +div.language-d::before { content: "D"; } +div.language-fortran::before { content: "Fortran"; } +div.language-go::before { content: "Go"; } +div.language-html::before { content: "HTML"; } +div.language-java::before { content: "Java"; } +div.language-julia::before { content: "Julia"; } +div.language-kotlin::before { content: "Kotlin"; } +div.language-lua::before { content: "Lua"; } +div.language-make::before { content: "Make"; } +div.language-matlab::before { content: "MATLAB"; } +div.language-opencl::before { content: "OpenCL"; } +div.language-perl::before { content: "Perl"; } +div.language-python::before { content: "Python"; } +div.language-r::before { content: "R"; } +div.language-ruby::before { content: "Ruby"; } +div.language-rust::before { content: "Rust"; } +div.language-scala::before { content: "Scala"; } +div.language-sql::before { content: "SQL"; } +div.language-vulkan::before { content: "Vulkan"; } // Tab panels are used on Setup pages to show instructions for different Operating Systems .tab-pane {