From ecc2efa23864894301ee3991f84804f737d07a84 Mon Sep 17 00:00:00 2001 From: Erin Becker Date: Tue, 27 Feb 2018 15:29:55 -0800 Subject: [PATCH 01/79] Remove out-of-date CoC language --- CONDUCT.md | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/CONDUCT.md b/CONDUCT.md index 5e4943b4..acf6fb69 100644 --- a/CONDUCT.md +++ b/CONDUCT.md @@ -4,42 +4,9 @@ title: "Contributor Code of Conduct" permalink: /conduct/ --- As contributors and maintainers of this project, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, -updating documentation, -submitting pull requests or patches, -and other activities. - -We are committed to making participation in this project a harassment-free experience for everyone, -regardless of level of experience, -gender, -gender identity and expression, -sexual orientation, -disability, -personal appearance, -body size, -race, -ethnicity, -age, -or religion. - -Examples of unacceptable behavior by participants include the use of sexual language or imagery, -derogatory comments or personal attacks, -trolling, -public or private harassment, -insults, -or other unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to our [Code of Conduct][coc]. -Project maintainers who do not follow the Code of Conduct may be removed from the project team. +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]. - -- [Software and Data Carpentry Code of Conduct][coc] -- [Code of Conduct Reporting Guide][coc-reporting] - {% include links.md %} From e4dd6164ea3ecd478202c9d341c01b9f599d53e8 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Sat, 3 Mar 2018 13:01:39 +0100 Subject: [PATCH 02/79] Link DOIs to preferred resolver --- _includes/lc/intro.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/lc/intro.html b/_includes/lc/intro.html index 6794b542..a4a53eca 100644 --- a/_includes/lc/intro.html +++ b/_includes/lc/intro.html @@ -14,6 +14,6 @@ Library Carpentry introduces you to the fundamentals of computing and provides you with a platform for further self-directed learning. For more information on what we teach and why, please see our paper - "Library Carpentry: software skills training for library professionals". + "Library Carpentry: software skills training for library professionals".

From ad4cd67d971e426afee178259fe52b62072db0ae Mon Sep 17 00:00:00 2001 From: Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com> Date: Mon, 19 Mar 2018 08:11:15 +0100 Subject: [PATCH 03/79] Fix source of typo #646 --- bin/lesson_initialize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index acb253b5..cf9735ec 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -87,7 +87,7 @@ There are many ways to contribute, from writing new exercises and improving existing ones to updating or filling in the documentation -and and submitting [bug reports][issues] +and submitting [bug reports][issues] about things that don't work, aren't clear, or are missing. If you are looking for ideas, please see the 'Issues' tab for a list of issues associated with this repository, From cd798b9e3ca478601153882bc39fe03043ddd348 Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Thu, 22 Mar 2018 19:13:00 +0000 Subject: [PATCH 04/79] Add swc-releases to _includes/links Close #217 --- _includes/links.md | 1 + 1 file changed, 1 insertion(+) diff --git a/_includes/links.md b/_includes/links.md index 273d63ea..a5af4246 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -28,6 +28,7 @@ [ruby-installer]: https://rubyinstaller.org/ [rubygems]: https://rubygems.org/pages/download/ [styles]: https://github.com/swcarpentry/styles/ +[swc-releases]: https://github.com/swcarpentry/swc-releases [training]: https://swcarpentry.github.io/instructor-training/ [workshop-repo]: {{ site.workshop_repo }} [yaml]: http://yaml.org/ From 91a6d2ab214b6fcc79013102e3af1061b6d7dbf0 Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Thu, 22 Mar 2018 19:17:17 +0000 Subject: [PATCH 05/79] Update Trademark Close #211 --- LICENSE.md | 8 ++++---- _includes/links.md | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 0e87b587..e4dde15c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -74,10 +74,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Trademark "Software Carpentry" and "Data Carpentry" and their respective logos -are registered trademarks of [NumFOCUS][numfocus]. +are registered trademarks of [Community Initiatives][CI]. [cc-by-human]: https://creativecommons.org/licenses/by/4.0/ [cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode -[mit-license]: https://opensource.org/licenses/mit-license.html -[numfocus]: https://numfocus.org/ -[osi]: https://opensource.org +[mit-license]: http://opensource.org/licenses/mit-license.html +[ci]: http://communityin.org/ +[osi]: http://opensource.org diff --git a/_includes/links.md b/_includes/links.md index a5af4246..ce8660e9 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -17,6 +17,7 @@ [mit-license]: https://opensource.org/licenses/mit-license.html [morea]: https://morea-framework.github.io/ [numfocus]: https://numfocus.org/ +[ci]: http://communityin.org/ [osi]: https://opensource.org [pandoc]: https://pandoc.org/ [paper-now]: https://github.com/PeerJ/paper-now From ae4a6939c6622f29a15dc642e55f6602807e1c5d Mon Sep 17 00:00:00 2001 From: Raniere Silva Date: Thu, 22 Mar 2018 19:21:39 +0000 Subject: [PATCH 06/79] Improve language on CONTRIBUTING file As @marwahaha said > "master repository" feels overloaded, > since typically "master" refers to a branch name. We are going to use "originating repository". --- bin/lesson_initialize.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index cf9735ec..aeffdec7 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -126,22 +126,22 @@ 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: -1. Fork the master repository to your GitHub profile. +1. Fork the originating repository to your GitHub profile. 2. Within your version of the forked repository, move to the `gh-pages` branch and create a new branch for each significant change being made. 3. Navigate to the file(s) you wish to change within the new branches and make revisions as required. 4. Commit all changed files within the appropriate branches. 5. Create individual pull requests from each of your changed branches -to the `gh-pages` branch within the master repository. +to the `gh-pages` branch within the originating repository. 6. If you receive feedback, make changes using your issue-specific branches of the forked repository and the pull requests will update automatically. 7. Repeat as needed until all feedback has been addressed. -When starting work, please make sure your clone of the master `gh-pages` branch is up-to-date +When starting work, please make sure your clone of the originating `gh-pages` branch is up-to-date before creating your own revision-specific branch(es) from there. Additionally, please only work from your newly-created branch(es) and *not* -your clone of the master `gh-pages` branch. -Lastly, published copies of all the lessons are available in the `gh-pages` branch of the master +your clone of the originating `gh-pages` branch. +Lastly, published copies of all the lessons are available in the `gh-pages` branch of the originating repository for reference while revising. ## Other Resources From d46a5784feaa2f5b0c4111eae23a020518723311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Wed, 4 Apr 2018 10:01:36 -0400 Subject: [PATCH 07/79] don't break words in code --- assets/css/bootstrap.css | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/css/bootstrap.css b/assets/css/bootstrap.css index 0fe7cd5b..6704f50c 100644 --- a/assets/css/bootstrap.css +++ b/assets/css/bootstrap.css @@ -107,6 +107,7 @@ pre, samp { font-family: monospace, monospace; font-size: 1em; + hyphens: none; } button, input, From 1182f75f75c097822796cd4b2da876f4d7f9655f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Mon, 9 Apr 2018 16:06:44 -0400 Subject: [PATCH 08/79] check hex color using lowercase --- bin/repo_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/repo_check.py b/bin/repo_check.py index fd04ce93..ba1edf5b 100755 --- a/bin/repo_check.py +++ b/bin/repo_check.py @@ -131,7 +131,7 @@ def check_labels(reporter, repo_url): overlap = set(EXPECTED.keys()).intersection(set(actual.keys())) for name in sorted(overlap): - reporter.check(EXPECTED[name] == actual[name], + reporter.check(EXPECTED[name].lower() == actual[name].lower(), None, 'Color mis-match for label {0} in {1}: expected {2}, found {3}', name, repo_url, EXPECTED[name], actual[name]) From fd9e75ee8a62d40e6f7ebbb6882dde68cf7fc3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Mon, 9 Apr 2018 16:07:20 -0400 Subject: [PATCH 09/79] update github labels --- bin/repo_check.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/bin/repo_check.py b/bin/repo_check.py index ba1edf5b..d8f379cc 100755 --- a/bin/repo_check.py +++ b/bin/repo_check.py @@ -35,15 +35,26 @@ # Expected labels and colors. EXPECTED = { - 'bug' : 'bd2c00', - 'discussion' : 'fc8dc1', - 'enhancement' : '9cd6dc', - 'help-wanted' : 'f4fd9c', - 'instructor-training' : '6e5494', - 'newcomer-friendly' : 'eec275', - 'question' : '808040', - 'template-and-tools' : '2b3990', - 'work-in-progress' : '7ae78e' + 'help wanted' : 'dcecc7', + 'status:in progress' : '9bcc65', + 'status:changes requested' : '679f38', + 'status:wait' : 'fff2df', + 'status:refer to cac' : 'ffdfb2', + 'status:need more info' : 'ee6c00', + 'status:blocked' : 'e55100', + 'status:out of scope' : 'eeeeee', + 'status:duplicate' : 'bdbdbd', + 'type:typo text' : 'f8bad0', + 'type:bug' : 'eb3f79', + 'type:formatting' : 'ac1357', + 'type:template and tools' : '7985cb', + 'type:instructor guide' : '00887a', + 'type:discussion' : 'b2e5fc', + 'type:enhancement' : '7fdeea', + 'type:clarification' : '00acc0', + 'type:teaching example' : 'ced8dc', + 'good first issue' : 'ffeb3a', + 'high priority' : 'd22e2e' } From e611262a108d1290ada4aed18e4fa3f888b0bf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Wed, 11 Apr 2018 09:26:04 -0400 Subject: [PATCH 10/79] use CRAN canonical addresses for packages --- _includes/links.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/links.md b/_includes/links.md index ce8660e9..be3008f7 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -4,9 +4,9 @@ [email]: mailto:lessons@software-carpentry.org [contrib-covenant]: https://contributor-covenant.org/ [contributing]: {{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md -[cran-checkpoint]: https://cran.r-project.org/web/packages/checkpoint/index.html -[cran-knitr]: https://cran.r-project.org/web/packages/knitr/index.html -[cran-stringr]: https://cran.r-project.org/web/packages/stringr/index.html +[cran-checkpoint]: https://cran.r-project.org/package=checkpoint +[cran-knitr]: https://cran.r-project.org/package=knitr +[cran-stringr]: https://cran.r-project.org/package=stringr [github-importer]: https://import.github.com/ [importer]: https://github.com/new/import [jekyll-collection]: https://jekyllrb.com/docs/collections/ From 2df359cd12f55b02179407c8e1ab855e5abaea5d Mon Sep 17 00:00:00 2001 From: Jonah Duckles Date: Fri, 13 Apr 2018 13:09:19 +1200 Subject: [PATCH 11/79] Updating to handbook as canonical source for CoC --- _includes/links.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/links.md b/_includes/links.md index be3008f7..7fb21413 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -33,6 +33,6 @@ [training]: https://swcarpentry.github.io/instructor-training/ [workshop-repo]: {{ site.workshop_repo }} [yaml]: http://yaml.org/ -[coc]: https://software-carpentry.org/conduct/ -[coc-reporting]: https://software-carpentry.org/CoC-reporting/ +[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html +[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html#reporting-guidelines [lesson-example]: https://swcarpentry.github.io/lesson-example/ From e7f98a6136639ecf0eed09535f8b801dae2ff49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Michonneau?= Date: Tue, 17 Apr 2018 10:53:24 -0400 Subject: [PATCH 12/79] fix github meta data --- _layouts/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_layouts/base.html b/_layouts/base.html index f1e90d1a..a188a714 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -8,7 +8,7 @@ - + From 26ccd8cd2d0960f7a8e86d5a97b3259e8ef611e7 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Sun, 18 Mar 2018 18:35:40 +0100 Subject: [PATCH 13/79] Secure hyperlinks --- _includes/links.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/links.md b/_includes/links.md index 7fb21413..965c5108 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -23,7 +23,7 @@ [paper-now]: https://github.com/PeerJ/paper-now [python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/ [pyyaml]: https://pypi.python.org/pypi/PyYAML -[r-markdown]: http://rmarkdown.rstudio.com/ +[r-markdown]: https://rmarkdown.rstudio.com/ [rstudio]: https://www.rstudio.com/ [ruby-install-guide]: https://www.ruby-lang.org/en/downloads/ [ruby-installer]: https://rubyinstaller.org/ From 3ed286691146cd05ad1bf10582fdfa5875599fa0 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Sun, 18 Mar 2018 18:38:17 +0100 Subject: [PATCH 14/79] Resort hyperlinks alphabetically --- _includes/links.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/_includes/links.md b/_includes/links.md index 965c5108..3d8dbfbd 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -1,12 +1,16 @@ [cc-by-human]: https://creativecommons.org/licenses/by/4.0/ [cc-by-legal]: https://creativecommons.org/licenses/by/4.0/legalcode +[ci]: http://communityin.org/ +[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html#reporting-guidelines +[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html +[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ [concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ -[email]: mailto:lessons@software-carpentry.org [contrib-covenant]: https://contributor-covenant.org/ [contributing]: {{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md -[cran-checkpoint]: https://cran.r-project.org/package=checkpoint -[cran-knitr]: https://cran.r-project.org/package=knitr -[cran-stringr]: https://cran.r-project.org/package=stringr +[cran-checkpoint]: https://cran.r-project.org/web/packages/checkpoint/index.html +[cran-knitr]: https://cran.r-project.org/web/packages/knitr/index.html +[cran-stringr]: https://cran.r-project.org/web/packages/stringr/index.html +[email]: mailto:lessons@software-carpentry.org [github-importer]: https://import.github.com/ [importer]: https://github.com/new/import [jekyll-collection]: https://jekyllrb.com/docs/collections/ @@ -14,10 +18,10 @@ [jekyll-windows]: http://jekyll-windows.juthilo.com/ [jekyll]: https://jekyllrb.com/ [jupyter]: https://jupyter.org/ +[lesson-example]: https://swcarpentry.github.io/lesson-example/ [mit-license]: https://opensource.org/licenses/mit-license.html [morea]: https://morea-framework.github.io/ [numfocus]: https://numfocus.org/ -[ci]: http://communityin.org/ [osi]: https://opensource.org [pandoc]: https://pandoc.org/ [paper-now]: https://github.com/PeerJ/paper-now @@ -33,6 +37,3 @@ [training]: https://swcarpentry.github.io/instructor-training/ [workshop-repo]: {{ site.workshop_repo }} [yaml]: http://yaml.org/ -[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html -[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html#reporting-guidelines -[lesson-example]: https://swcarpentry.github.io/lesson-example/ From 0d0f943bbf90d0900bb7cb5521a92f31380f7d89 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Sun, 18 Mar 2018 18:38:26 +0100 Subject: [PATCH 15/79] Reflect merger --- _includes/links.md | 1 - 1 file changed, 1 deletion(-) diff --git a/_includes/links.md b/_includes/links.md index 3d8dbfbd..63e9b002 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -34,6 +34,5 @@ [rubygems]: https://rubygems.org/pages/download/ [styles]: https://github.com/swcarpentry/styles/ [swc-releases]: https://github.com/swcarpentry/swc-releases -[training]: https://swcarpentry.github.io/instructor-training/ [workshop-repo]: {{ site.workshop_repo }} [yaml]: http://yaml.org/ From bf65236030110a5e17c47115061068b0260976e9 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com> Date: Sun, 18 Mar 2018 18:47:22 +0100 Subject: [PATCH 16/79] Convert CRAN links to preferred, canonical form https://cran.r-project.org/doc/manuals/r-patched/R-exts.html#Specifying-URLs --- _includes/links.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/links.md b/_includes/links.md index 63e9b002..2fb9f74c 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -7,9 +7,9 @@ [concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ [contrib-covenant]: https://contributor-covenant.org/ [contributing]: {{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md -[cran-checkpoint]: https://cran.r-project.org/web/packages/checkpoint/index.html -[cran-knitr]: https://cran.r-project.org/web/packages/knitr/index.html -[cran-stringr]: https://cran.r-project.org/web/packages/stringr/index.html +[cran-checkpoint]: https://cran.r-project.org/package=checkpoint +[cran-knitr]: https://cran.r-project.org/package=knitr +[cran-stringr]: https://cran.r-project.org/package=stringr [email]: mailto:lessons@software-carpentry.org [github-importer]: https://import.github.com/ [importer]: https://github.com/new/import From 51293be6b00cfca6b1edf9d8d9613c45aaec4fb8 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 19 Apr 2018 13:01:40 -0500 Subject: [PATCH 17/79] links.md: remove duplicate line --- _includes/links.md | 1 - 1 file changed, 1 deletion(-) diff --git a/_includes/links.md b/_includes/links.md index 2fb9f74c..be88dac8 100644 --- a/_includes/links.md +++ b/_includes/links.md @@ -4,7 +4,6 @@ [coc-reporting]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html#reporting-guidelines [coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html [concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ -[concept-maps]: https://carpentries.github.io/instructor-training/05-memory/ [contrib-covenant]: https://contributor-covenant.org/ [contributing]: {{ site.github.repository_url }}/blob/gh-pages/CONTRIBUTING.md [cran-checkpoint]: https://cran.r-project.org/package=checkpoint From f82fed8a8cb8d75147733eb9057a6a6c453a2007 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 19 Apr 2018 16:20:58 -0500 Subject: [PATCH 18/79] bin/util.py: fix error handling for Python 2 --- bin/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/util.py b/bin/util.py index 0cc8de69..f4680b43 100644 --- a/bin/util.py +++ b/bin/util.py @@ -160,7 +160,7 @@ def load_yaml(filename): try: with open(filename, 'r') as reader: return yaml.load(reader) - except (yaml.YAMLError, FileNotFoundError) as e: + except (yaml.YAMLError, IOError) as e: print('Unable to load YAML file {0}:\n{1}'.format(filename, e), file=sys.stderr) sys.exit(1) From 93eb566a61595e7b00a36a934c605746167b01dc Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Fri, 20 Apr 2018 12:50:50 +0300 Subject: [PATCH 19/79] convert to py3.4 syntax, a few cleanups --- bin/lesson_check.py | 91 +++++++++++++++++++--------------------- bin/lesson_initialize.py | 5 +-- bin/repo_check.py | 59 ++++++++++++++------------ bin/test_lesson_check.py | 4 +- bin/util.py | 26 ++++++------ bin/workshop_check.py | 25 +++++------ 6 files changed, 107 insertions(+), 103 deletions(-) diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 66f6310c..a9b6c9c8 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -4,15 +4,14 @@ Check lesson files and their contents. """ -from __future__ import print_function -import sys + import os import glob -import json import re from optparse import OptionParser -from util import Reporter, read_markdown, load_yaml, check_unwanted_files, require, IMAGE_FILE_SUFFIX +from util import (Reporter, read_markdown, load_yaml, check_unwanted_files, + require) __version__ = '0.3' @@ -23,8 +22,9 @@ # FIXME: We do not yet validate whether any files have the required # YAML headers, but should in the future. # The '%' is replaced with the source directory path for checking. -# Episodes are handled specially, and extra files in '_extras' are also handled specially. -# This list must include all the Markdown files listed in the 'bin/initialize' script. +# Episodes are handled specially, and extra files in '_extras' are also handled +# specially. This list must include all the Markdown files listed in the +# 'bin/initialize' script. REQUIRED_FILES = { '%/CONDUCT.md': True, '%/CONTRIBUTING.md': False, @@ -101,6 +101,7 @@ # How long are lines allowed to be? MAX_LINE_LEN = 100 + def main(): """Main driver.""" @@ -110,9 +111,9 @@ def main(): 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, docs.keys()) + check_fileset(args.source_dir, args.reporter, list(docs.keys())) check_unwanted_files(args.source_dir, args.reporter) - for filename in docs.keys(): + for filename in list(docs.keys()): checker = create_checker(args, filename, docs[filename]) checker.check() @@ -160,8 +161,10 @@ def check_config(reporter, source_dir): config_file = os.path.join(source_dir, '_config.yml') config = load_yaml(config_file) - reporter.check_field(config_file, 'configuration', config, 'kind', 'lesson') - reporter.check_field(config_file, 'configuration', config, 'carpentry', ('swc', 'dc', 'lc')) + reporter.check_field(config_file, 'configuration', + config, 'kind', 'lesson') + reporter.check_field(config_file, 'configuration', + config, 'carpentry', ('swc', 'dc', 'lc')) reporter.check_field(config_file, 'configuration', config, 'title') reporter.check_field(config_file, 'configuration', config, 'email') @@ -235,17 +238,17 @@ def check_fileset(source_dir, reporter, filenames_present): if m and m.group(1): seen.append(m.group(1)) else: - reporter.add(None, 'Episode {0} has badly-formatted filename', filename) + reporter.add( + None, 'Episode {0} has badly-formatted filename', filename) # Check for duplicate episode numbers. reporter.check(len(seen) == len(set(seen)), - None, - 'Duplicate episode numbers {0} vs {1}', - sorted(seen), sorted(set(seen))) + None, + 'Duplicate episode numbers {0} vs {1}', + sorted(seen), sorted(set(seen))) # Check that numbers are consecutive. - seen = [int(s) for s in seen] - seen.sort() + seen = sorted([int(s) for s in seen]) clean = True for i in range(len(seen) - 1): clean = clean and ((seen[i+1] - seen[i]) == 1) @@ -271,7 +274,7 @@ def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): super(CheckBase, self).__init__() self.args = args - self.reporter = self.args.reporter # for convenience + self.reporter = self.args.reporter # for convenience self.filename = filename self.metadata = metadata self.metadata_len = metadata_len @@ -281,7 +284,6 @@ def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): self.layout = None - def check(self): """Run tests.""" @@ -292,7 +294,6 @@ def check(self): self.check_codeblock_classes() self.check_defined_link_references() - def check_metadata(self): """Check the YAML metadata.""" @@ -301,53 +302,51 @@ def check_metadata(self): 'Missing metadata entirely') if self.metadata and (self.layout is not None): - self.reporter.check_field(self.filename, 'metadata', self.metadata, 'layout', self.layout) - + self.reporter.check_field( + self.filename, 'metadata', self.metadata, 'layout', self.layout) def check_line_lengths(self): """Check the raw text of the lesson body.""" if self.args.line_lengths: - over = [i for (i, l, n) in self.lines if (n > MAX_LINE_LEN) and (not l.startswith('!'))] + over = [i for (i, l, n) in self.lines if ( + n > MAX_LINE_LEN) and (not l.startswith('!'))] self.reporter.check(not over, self.filename, 'Line(s) are too long: {0}', ', '.join([str(i) for i in over])) - def check_trailing_whitespace(self): """Check for whitespace at the ends of lines.""" if self.args.trailing_whitespace: - trailing = [i for (i, l, n) in self.lines if P_TRAILING_WHITESPACE.match(l)] + trailing = [ + i for (i, l, n) in self.lines if P_TRAILING_WHITESPACE.match(l)] self.reporter.check(not trailing, self.filename, 'Line(s) end with whitespace: {0}', ', '.join([str(i) for i in trailing])) - def check_blockquote_classes(self): """Check that all blockquotes have known classes.""" - for node in self.find_all(self.doc, {'type' : 'blockquote'}): + for node in self.find_all(self.doc, {'type': 'blockquote'}): cls = self.get_val(node, 'attr', 'class') self.reporter.check(cls in KNOWN_BLOCKQUOTES, (self.filename, self.get_loc(node)), 'Unknown or missing blockquote type {0}', cls) - def check_codeblock_classes(self): """Check that all code blocks have known classes.""" - for node in self.find_all(self.doc, {'type' : 'codeblock'}): + for node in self.find_all(self.doc, {'type': 'codeblock'}): cls = self.get_val(node, 'attr', 'class') self.reporter.check(cls in KNOWN_CODEBLOCKS, (self.filename, self.get_loc(node)), 'Unknown or missing code block type {0}', cls) - def check_defined_link_references(self): """Check that defined links resolve in the file. @@ -355,7 +354,7 @@ def check_defined_link_references(self): """ result = set() - for node in self.find_all(self.doc, {'type' : 'text'}): + for node in self.find_all(self.doc, {'type': 'text'}): for match in P_INTERNAL_LINK_REF.findall(node['value']): text = match[0] link = match[1] @@ -366,11 +365,10 @@ def check_defined_link_references(self): 'Internally-defined links may be missing definitions: {0}', ', '.join(sorted(result))) - def find_all(self, node, pattern, accum=None): """Find all matches for a pattern.""" - assert type(pattern) == dict, 'Patterns must be dictionaries' + assert isinstance(pattern, dict), 'Patterns must be dictionaries' if accum is None: accum = [] if self.match(node, pattern): @@ -379,7 +377,6 @@ def find_all(self, node, pattern, accum=None): self.find_all(child, pattern, accum) return accum - def match(self, node, pattern): """Does this node match the given pattern?""" @@ -387,15 +384,14 @@ def match(self, node, pattern): if key not in node: return False val = pattern[key] - if type(val) == str: + if isinstance(val, str): if node[key] != val: return False - elif type(val) == dict: + elif isinstance(val, dict): if not self.match(node[key], val): return False return True - def get_val(self, node, *chain): """Get value one or more levels down.""" @@ -406,7 +402,6 @@ def get_val(self, node, *chain): break return curr - def get_loc(self, node): """Convenience method to get node's line number.""" @@ -420,8 +415,8 @@ class CheckNonJekyll(CheckBase): """Check a file that isn't translated by Jekyll.""" def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): - super(CheckNonJekyll, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) - + super(CheckNonJekyll, self).__init__( + args, filename, metadata, metadata_len, text, lines, doc) def check_metadata(self): self.reporter.check(self.metadata is None, @@ -433,7 +428,8 @@ class CheckIndex(CheckBase): """Check the main index page.""" def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): - super(CheckIndex, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) + super(CheckIndex, self).__init__(args, filename, + metadata, metadata_len, text, lines, doc) self.layout = 'lesson' def check_metadata(self): @@ -447,8 +443,8 @@ class CheckEpisode(CheckBase): """Check an episode page.""" def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): - super(CheckEpisode, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) - + super(CheckEpisode, self).__init__(args, filename, + metadata, metadata_len, text, lines, doc) def check(self): """Run extra tests.""" @@ -456,7 +452,6 @@ def check(self): super(CheckEpisode, self).check() self.check_reference_inclusion() - def check_metadata(self): super(CheckEpisode, self).check_metadata() if self.metadata: @@ -470,19 +465,17 @@ def check_metadata(self): else: self.check_metadata_fields(TEACHING_METADATA_FIELDS) - def check_metadata_fields(self, expected): for (name, type_) in expected: if name not in self.metadata: self.reporter.add(self.filename, 'Missing metadata field {0}', name) - elif type(self.metadata[name]) != type_: + elif not isinstance(self.metadata[name], type_): self.reporter.add(self.filename, '"{0}" has wrong type in metadata ({1} instead of {2})', name, type(self.metadata[name]), type_) - def check_reference_inclusion(self): """Check that links file has been included.""" @@ -507,7 +500,8 @@ class CheckReference(CheckBase): """Check the reference page.""" def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): - super(CheckReference, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) + super(CheckReference, self).__init__( + args, filename, metadata, metadata_len, text, lines, doc) self.layout = 'reference' @@ -515,7 +509,8 @@ class CheckGeneric(CheckBase): """Check a generic page.""" def __init__(self, args, filename, metadata, metadata_len, text, lines, doc): - super(CheckGeneric, self).__init__(args, filename, metadata, metadata_len, text, lines, doc) + super(CheckGeneric, self).__init__(args, filename, + metadata, metadata_len, text, lines, doc) self.layout = 'page' diff --git a/bin/lesson_initialize.py b/bin/lesson_initialize.py index aeffdec7..7b0b6151 100755 --- a/bin/lesson_initialize.py +++ b/bin/lesson_initialize.py @@ -3,7 +3,6 @@ """Initialize a newly-created repository.""" -from __future__ import print_function import sys import os @@ -121,7 +120,7 @@ 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]. +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. 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: @@ -279,7 +278,7 @@ ROOT_AIO_MD = '''\ --- -layout: page +layout: page root: . ---