Skip to content

Commit

Permalink
Merge pull request #338 from zkamvar/update-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
fmichonneau authored Apr 16, 2021
2 parents 5eee7f1 + e2c2d8c commit ba38508
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 38 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,7 +45,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: |
Expand Down Expand Up @@ -96,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
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +29,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: |
Expand Down Expand Up @@ -62,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
Expand Down Expand Up @@ -97,6 +99,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
Expand All @@ -105,7 +112,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 ..
Expand Down
3 changes: 2 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,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
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -21,25 +21,25 @@ 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


# 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
Expand All @@ -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 \
Expand All @@ -60,14 +60,17 @@ 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
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 {} \;
Expand All @@ -85,7 +88,7 @@ clean-rmd :
.PHONY : workshop-check

## * workshop-check : check workshop homepage
workshop-check :
workshop-check : python
@${PYTHON} bin/workshop_check.py .


Expand Down Expand Up @@ -128,18 +131,18 @@ 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
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
Expand All @@ -157,6 +160,15 @@ lesson-fixme :
## IV. Auxililary (plumbing) 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
2 changes: 1 addition & 1 deletion _includes/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
19 changes: 19 additions & 0 deletions assets/css/lesson.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -287,6 +301,11 @@ span.fold-unfold {
}


p.image-with-shadow img,
img.image-with-shadow {
box-shadow: 0 6px 24px 0 #888;
}

//----------------------------------------
// Life cycle box
//----------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions bin/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ 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.
if ("@CRAN@" %in% repos) {
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() {
Expand Down
17 changes: 14 additions & 3 deletions bin/lesson_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.source_dir):
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()))
Expand Down Expand Up @@ -167,6 +170,10 @@ def parse_args():

return args

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

def check_config(reporter, source_dir):
"""Check configuration file."""
Expand All @@ -188,6 +195,8 @@ def check_config(reporter, source_dir):
reporter.check(defaults in config.get('defaults', []),
'configuration',
'"root" not set to "." in configuration')
if 'life_cycle' not in config:
config['life_cycle'] = None
return config['life_cycle']

def check_source_rmd(reporter, source_dir, parser):
Expand Down Expand Up @@ -390,7 +399,8 @@ 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)
Expand Down Expand Up @@ -490,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()
Expand Down
3 changes: 2 additions & 1 deletion bin/markdown_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
require "bundler/inline"

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)
2 changes: 1 addition & 1 deletion bin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bin/workshop_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"'

Expand Down

0 comments on commit ba38508

Please sign in to comment.