Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code documentation #5628

Merged
merged 41 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6d81e15
docs
hexylena Dec 10, 2024
6d98f9a
add fn
hexylena Dec 10, 2024
087d1aa
enable documenting without maintaining a separate wiki
hexylena Dec 10, 2024
0cc66f5
more documentation
hexylena Dec 10, 2024
070c57b
more docs
hexylena Dec 10, 2024
caff3a9
Fix longstanding mis-detection of bad headers in code blocks
hexylena Dec 10, 2024
de9e24a
finish documenting linter
hexylena Dec 10, 2024
3d92a1e
more docs
hexylena Dec 10, 2024
e013740
more documentation
hexylena Dec 10, 2024
3ed2924
more docs
hexylena Dec 10, 2024
3cd670d
add ADR templates
hexylena Dec 12, 2024
699fbb5
improve video library experience
hexylena Dec 12, 2024
c68df6b
further document jekyll
hexylena Dec 12, 2024
d63d404
rename some classes to structure them more sanely
hexylena Dec 12, 2024
17c582d
more documentation
hexylena Dec 12, 2024
45973e5
incorrect size
hexylena Dec 12, 2024
5502fdd
Fixes https://github.com/galaxyproject/training-material/issues/5615
hexylena Dec 12, 2024
d770408
another module rename
hexylena Dec 12, 2024
c8da5cc
-w ahh change, another restructuring
hexylena Dec 12, 2024
6891755
Now unused
hexylena Dec 12, 2024
6643f43
cont
hexylena Dec 12, 2024
8a84493
restructure
hexylena Dec 12, 2024
385dc28
final restructure
hexylena Dec 12, 2024
6192ed2
ok really final
hexylena Dec 12, 2024
391594b
fix doc location
hexylena Dec 12, 2024
91a0225
more restructures
hexylena Dec 12, 2024
2ce8809
restructure generators more sanely
hexylena Dec 12, 2024
68106a4
more docs
hexylena Dec 12, 2024
8fcf5b7
more ADRs
hexylena Dec 12, 2024
914e6a2
much nicer theme
hexylena Dec 12, 2024
5f57713
not a tag
hexylena Dec 12, 2024
a120ba8
missing alt
hexylena Dec 12, 2024
9c803bf
move API generator to post-write hook
hexylena Dec 12, 2024
d5ca5ec
ignore short urls
hexylena Dec 12, 2024
c016864
move more to prod
hexylena Dec 12, 2024
05cd6c5
move to prod
hexylena Dec 12, 2024
f388cf2
prod exceptions elsehwere, fix module name
hexylena Dec 12, 2024
18b9f5c
ignore API urls lol
hexylena Dec 12, 2024
fb44351
innføre by tool in tests
hexylena Dec 12, 2024
654d13f
Make quizzes local only + more accessible
hexylena Dec 13, 2024
5c0fe82
Make the results accessible
hexylena Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
- name: Validate all links, enforce alt text
run: |
bundle exec htmlproofer \
--ignore-urls "/.*localhost.*/","/.*vimeo\.com.*/","/.*gitter\.im.*/","/.*drmaa\.org.*/","/.*slides.html#.*/,/#embedded_jbrowse/","/.*videos.*.mp4.png/","/krona_(all|multisample).html/","/workflows\/trs_import/" \
--ignore-files "/.*krona.*\.html/","/.*\/files\/.*/","/.*\/node_modules\/.*/","/\/tutorials\/.*\/docker\//","/.*content.html/","/.*recentrifuge.*\.html/" \
--ignore-urls "/.*localhost.*/","/.*vimeo\.com.*/","/.*gitter\.im.*/","/.*drmaa\.org.*/","/.*slides.html#.*/,/#embedded_jbrowse/","/.*videos.*.mp4.png/","/krona_(all|multisample).html/","/workflows\/trs_import/","/api/","/by-tool/" \
--ignore-files "/.*krona.*\.html/","/.*\/files\/.*/","/.*\/node_modules\/.*/","/\/tutorials\/.*\/docker\//","/.*content.html/","/.*recentrifuge.*\.html/","/short/" \
--swap-urls "github.com/galaxyproject/training-material/tree/main:github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_HEAD_REF}" \
--disable-external=true \
--enforce-https=false \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
curl -L https://edamontology.org/EDAM.csv > metadata/EDAM.csv
make rebuild-search-index ACTIVATE_ENV=pwd
cat metadata/swagger.yaml | python bin/yaml2json.py > api/swagger.json
rdoc bin _plugins/ --output gtn_rdoc
rdoc bin _plugins/ --output gtn_rdoc --template rorvswild

- name: Build Site
run: |
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ gem 'commander'

# RO-Crates
gem 'rubyzip', '~> 2.3.0'

gem 'rorvswild_theme_rdoc'
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.3.9)
rorvswild_theme_rdoc (0.2)
rouge (4.1.3)
rubyzip (2.3.2)
safe_yaml (1.0.5)
Expand Down Expand Up @@ -131,6 +132,7 @@ DEPENDENCIES
kwalify
nokogiri (>= 1.10.4)
pkg-config
rorvswild_theme_rdoc
rubyzip (~> 2.3.0)
webrick

Expand Down
97 changes: 90 additions & 7 deletions _includes/quiz.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,94 @@
{% endif %}
{% endfor %}

<div markdown="1">
> <div class="box-title" aria-label="quiz box: {{ quiz.title | replace: '"', '&quot;' }}"><i class="far fa-question-circle" aria-hidden="true"></i><span class="visually-hidden"></span> Quiz: {{ quiz.title }}</div>
> Check your knowledge with a quiz!
>
> - [Self Study Mode]({% link quiz/quiz.html %}?mode=self&quiz={{ site.baseurl }}/{{ quiz.path }}) - do the quiz at your own pace, to check your understanding.
> - [Classroom Mode]({% link quiz/quiz.html %}?mode=teacher&quiz={{ site.baseurl }}/{{ quiz.path }}) - do the quiz synchronously with a classroom of students.
{: .question}
<blockquote class="comment" id="{{ quiz.id | slugify }}">
<div class="box-title comment-title">
<i class="far fa-comment-dots" aria-hidden="true"></i>
Quiz: {{ quiz.title }}
</div>


{% for question in quiz.questions %}
{% assign qnum = forloop.index %}
<form class="quiz-{{ quiz.id | slugify }} question-{{ qnum }}">
<b class="question-title"><span class="result"></span> Question {{ qnum }}: {{ question.title }}</b>

{% if question.image %}
<img src="{{ question.image }}" alt="Image for question {{ forloop.index }}" />
{% endif %}

{% unless question.type == "poll" %}
<ul>
{% for answer in question.answers %}

{%- capture is_correct -%}
{%- if question.type == "choose-1" -%}
{%- if answer == question.correct -%}correct{%- endif -%}
{%- elsif question.type == "choose-many" -%}
{%- for a in question.correct -%}{%- if answer == a -%}correct{%- endif -%}{%- endfor -%}
{%- endif -%}
{%- endcapture -%}

<li class="answer {{is_correct}}">
<span class="result"></span>
{% if question.type == "choose-1" %}
<input type="radio" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}"/>
{% elsif question.type == "choose-many" %}
<input type="checkbox" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}" />
{% elsif question.type == "free-text" %}
<input type="text" id="a-{{ qnum }}-{{ forloop.index }}" name="answer" value="{{ answer }}" class="answer-input {{is_correct}}"/>
{% endif %}

<label for="a-{{ qnum }}-{{ forloop.index }}">{{ answer }}</label>
</li>
{% endfor %}
</ul>
{% endunless %}
</form>
{% endfor %}

<div class="quiz-results" aria-live="polite" role="status">
</div>

<button type="submit" class="btn btn-primary" id="check-answers" onclick="checkQuiz('{{ quiz.id | slugify}}')">Check Answers</button>
</blockquote>

<script>
function checkQuiz(id){
var quiz = document.getElementById(id);
var correct = 0;
var total = document.querySelectorAll(`#${id} form`).length;
var questions = document.querySelectorAll(`#${id} form`);
for (var i = 0; i < questions.length; i++) {
var question = questions[i];
var answer = question.querySelectorAll("li.answer");
// Only grade completed questions.

var any_wrong = false;
var any_selected = [...answer].map(e => e.querySelector("input").checked).includes(true);
// Loop over the inputs for this question
if (any_selected) {
question.querySelectorAll("input").forEach((input) => {
if (input.checked != input.classList.contains('correct')) {
any_wrong = true;
}
});

answer.forEach((li) => {
li.querySelector('.result').innerHTML = li.classList.contains('correct') ? "✅" : "❌";
});

if (any_wrong) {
question.querySelector(".result").innerHTML = "❌";
} else {
question.querySelector(".result").innerHTML = "✅";
correct++;
}
} else {
question.querySelector(".result").innerHTML = "❓";
}
}
var result = correct / total * 100;
quiz.querySelector('.quiz-results').innerHTML = `<p>You got ${correct} out of ${total} correct (${parseInt(result)}%)</p>`;
}
</script>
2 changes: 2 additions & 0 deletions _layouts/tutorial_hands_on.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ <h1>{{ locale['faqs'] | default: "Frequently Asked Questions" }}</h1>
If not, please ask your question on the <a href="{{site.gitter_url}}">GTN Gitter Channel</a> or the
<a href="https://help.galaxyproject.org">Galaxy Help Forum</a>

<!--
{% if own_material.quiz %}
<h1 data-toc-skip>Quizzes</h1>
<p>Check your understanding with these quizzes</p>
Expand All @@ -338,6 +339,7 @@ <h2>{{ q.title }}</h2>
</ul>
{% endfor %}
{% endif %}
-->

{% if topic.references %}
<h1 data-toc-skip>Useful literature</h1>
Expand Down
90 changes: 46 additions & 44 deletions _plugins/abbr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,63 @@
require 'jekyll'

module Jekyll
##
# This class modifies the page contents to replace {abbr} with the associated
# abbreviation in a proper <abbr> tag. It's done as a generator because it's
# easier to operate once per page and be able to easily see if we've generated
# the abbreviation before.
#
# This could in theory operate as a simple tag, but I'm not sure how to keep
# track of "# of times seen per page" there.
class Abbreviate < Jekyll::Generator
safe true

def initialize(config) # :nodoc:
super
@config = config['abbreviate'] ||= {}
end
module Generators
##
# This class modifies the page contents to replace {abbr} with the associated
# abbreviation in a proper <abbr> tag. It's done as a generator because it's
# easier to operate once per page and be able to easily see if we've generated
# the abbreviation before.
#
# This could in theory operate as a simple tag, but I'm not sure how to keep
# track of "# of times seen per page" there.
class Abbreviate < Jekyll::Generator
safe true

def generate(site) # :nodoc:
site.pages
.reject { |page| skip_layout?(page.data['layout']) }
.each { |page| abbreviate page }
site.posts.docs
.reject { |post| skip_layout?(post.data['layout']) }
.each { |post| abbreviate post }
end
def initialize(config) # :nodoc:
super
@config = config['abbreviate'] ||= {}
end

def generate(site) # :nodoc:
site.pages
.reject { |page| skip_layout?(page.data['layout']) }
.each { |page| abbreviate page }
site.posts.docs
.reject { |post| skip_layout?(post.data['layout']) }
.each { |post| abbreviate post }
end

private
private

def abbreviate(page) # :nodoc:
return unless page.data.key?('abbreviations')
def abbreviate(page) # :nodoc:
return unless page.data.key?('abbreviations')

seen = {}
page.data['abbreviations'].each do |abbr, definition|
page.content = page.content.gsub(/\{(#{abbr})\}/) do
if seen.key?(abbr)
firstdef = false
else
firstdef = true
seen[abbr] = true
end
seen = {}
page.data['abbreviations'].each do |abbr, definition|
page.content = page.content.gsub(/\{(#{abbr})\}/) do
if seen.key?(abbr)
firstdef = false
else
firstdef = true
seen[abbr] = true
end

if firstdef
"#{definition} (#{abbr})"
else
"<abbr title=\"#{definition}\">#{abbr}</abbr>"
if firstdef
"#{definition} (#{abbr})"
else
"<abbr title=\"#{definition}\">#{abbr}</abbr>"
end
end
end
end
end

def skip_layout?(layout)
to_skip = @config['skip_layouts'] || []
def skip_layout?(layout)
to_skip = @config['skip_layouts'] || []

true if to_skip.empty?
true if to_skip.empty?

to_skip.include?(layout)
to_skip.include?(layout)
end
end
end
end
Loading
Loading