Merge branch 'gh-pages' into library-carpentry
[rnaseq-cwl-training.git] / bin / lesson_initialize.py
1 #!/usr/bin/env python
2
3 """Initialize a newly-created repository."""
4
5
6 from __future__ import print_function
7 import sys
8 import os
9
10 ROOT_AUTHORS = '''\
11 FIXME: list authors' names and email addresses.
12 '''
13
14 ROOT_CITATION = '''\
15 FIXME: describe how to cite this lesson.
16 '''
17
18 ROOT_CONTRIBUTING_MD = '''\
19 # Contributing
20
21 [Software Carpentry][swc-site] and [Data Carpentry][dc-site] are open source projects,
22 and we welcome contributions of all kinds:
23 new lessons,
24 fixes to existing material,
25 bug reports,
26 and reviews of proposed changes are all welcome.
27
28 ## Contributor Agreement
29
30 By contributing,
31 you agree that we may redistribute your work under [our license](LICENSE.md).
32 In exchange,
33 we will address your issues and/or assess your change proposal as promptly as we can,
34 and help you become a member of our community.
35 Everyone involved in [Software Carpentry][swc-site] and [Data Carpentry][dc-site]
36 agrees to abide by our [code of conduct](CONDUCT.md).
37
38 ## How to Contribute
39
40 The easiest way to get started is to file an issue
41 to tell us about a spelling mistake,
42 some awkward wording,
43 or a factual error.
44 This is a good way to introduce yourself
45 and to meet some of our community members.
46
47 1.  If you do not have a [GitHub][github] account,
48     you can [send us comments by email][contact].
49     However,
50     we will be able to respond more quickly if you use one of the other methods described below.
51
52 2.  If you have a [GitHub][github] account,
53     or are willing to [create one][github-join],
54     but do not know how to use Git,
55     you can report problems or suggest improvements by [creating an issue][issues].
56     This allows us to assign the item to someone
57     and to respond to it in a threaded discussion.
58
59 3.  If you are comfortable with Git,
60     and would like to add or change material,
61     you can submit a pull request (PR).
62     Instructions for doing this are [included below](#using-github).
63
64 ## Where to Contribute
65
66 1.  If you wish to change this lesson,
67     please work in <https://github.com/swcarpentry/FIXME>,
68     which can be viewed at <https://swcarpentry.github.io/FIXME>.
69
70 2.  If you wish to change the example lesson,
71     please work in <https://github.com/swcarpentry/lesson-example>,
72     which documents the format of our lessons
73     and can be viewed at <https://swcarpentry.github.io/lesson-example>.
74
75 3.  If you wish to change the template used for workshop websites,
76     please work in <https://github.com/swcarpentry/workshop-template>.
77     The home page of that repository explains how to set up workshop websites,
78     while the extra pages in <https://swcarpentry.github.io/workshop-template>
79     provide more background on our design choices.
80
81 4.  If you wish to change CSS style files, tools,
82     or HTML boilerplate for lessons or workshops stored in `_includes` or `_layouts`,
83     please work in <https://github.com/swcarpentry/styles>.
84
85 ## What to Contribute
86
87 There are many ways to contribute,
88 from writing new exercises and improving existing ones
89 to updating or filling in the documentation
90 and and submitting [bug reports][issues]
91 about things that don't work, aren't clear, or are missing.
92 If you are looking for ideas,
93 please see [the list of issues for this repository][issues],
94 or the issues for [Data Carpentry][dc-issues]
95 and [Software Carpentry][swc-issues] projects.
96
97 Comments on issues and reviews of pull requests are just as welcome:
98 we are smarter together than we are on our own.
99 Reviews from novices and newcomers are particularly valuable:
100 it's easy for people who have been using these lessons for a while
101 to forget how impenetrable some of this material can be,
102 so fresh eyes are always welcome.
103
104 ## What *Not* to Contribute
105
106 Our lessons already contain more material than we can cover in a typical workshop,
107 so we are usually *not* looking for more concepts or tools to add to them.
108 As a rule,
109 if you want to introduce a new idea,
110 you must (a) estimate how long it will take to teach
111 and (b) explain what you would take out to make room for it.
112 The first encourages contributors to be honest about requirements;
113 the second, to think hard about priorities.
114
115 We are also not looking for exercises or other material that only run on one platform.
116 Our workshops typically contain a mixture of Windows, Mac OS X, and Linux users;
117 in order to be usable,
118 our lessons must run equally well on all three.
119
120 ## Using GitHub
121
122 If you choose to contribute via GitHub,
123 you may want to look at
124 [How to Contribute to an Open Source Project on GitHub][how-contribute].
125 In brief:
126
127 1.  The published copy of the lesson is in the `gh-pages` branch of the repository
128     (so that GitHub will regenerate it automatically).
129     Please create all branches from that,
130     and merge the [master repository][repo]'s `gh-pages` branch into your `gh-pages` branch
131     before starting work.
132     Please do *not* work directly in your `gh-pages` branch,
133     since that will make it difficult for you to work on other contributions.
134
135 2.  We use [GitHub flow][github-flow] to manage changes:
136     1.  Create a new branch in your desktop copy of this repository for each significant change.
137     2.  Commit the change in that branch.
138     3.  Push that branch to your fork of this repository on GitHub.
139     4.  Submit a pull request from that branch to the [master repository][repo].
140     5.  If you receive feedback,
141         make changes on your desktop and push to your branch on GitHub:
142         the pull request will update automatically.
143
144 Each lesson has two maintainers who review issues and pull requests
145 or encourage others to do so.
146 The maintainers are community volunteers,
147 and have final say over what gets merged into the lesson.
148
149 ## Other Resources
150
151 General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]
152 happens on the [discussion mailing list][discuss-list],
153 which everyone is welcome to join.
154 You can also [reach us by email][contact].
155
156 [contact]: mailto:admin@software-carpentry.org
157 [dc-issues]: https://github.com/issues?q=user%3Adatacarpentry
158 [dc-lessons]: http://datacarpentry.org/lessons/
159 [dc-site]: http://datacarpentry.org/
160 [discuss-list]: http://lists.software-carpentry.org/listinfo/discuss
161 [example-site]: https://swcarpentry.github.io/lesson-example/
162 [github]: http://github.com
163 [github-flow]: https://guides.github.com/introduction/flow/
164 [github-join]: https://github.com/join
165 [how-contribute]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
166 [issues]: https://github.com/swcarpentry/FIXME/issues/
167 [repo]: https://github.com/swcarpentry/FIXME/
168 [swc-issues]: https://github.com/issues?q=user%3Aswcarpentry
169 [swc-lessons]: http://software-carpentry.org/lessons/
170 [swc-site]: http://software-carpentry.org/
171 '''
172
173 ROOT_CONFIG_YML = '''\
174 #------------------------------------------------------------
175 # Values for this lesson.
176 #------------------------------------------------------------
177
178 # Which carpentry is this ("swc", "dc", or "lc")?
179 carpentry: "swc"
180
181 # Overall title for pages.
182 title: "Lesson Title"
183
184 # Contact.  This *must* include the protocol: if it's an email
185 # address, it must look like "mailto:lessons@software-carpentry.org",
186 # or if it's a URL, "https://gitter.im/username/ProjectName".
187 contact: "mailto:lessons@software-carpentry.org"
188
189 #------------------------------------------------------------
190 # Generic settings (should not need to change).
191 #------------------------------------------------------------
192
193 # What kind of thing is this ("workshop" or "lesson")?
194 kind: "lesson"
195
196 # Magic to make URLs resolve both locally and on GitHub.
197 # See https://help.github.com/articles/repository-metadata-on-github-pages/.
198 repository: <USERNAME>/<PROJECT>
199
200 # Sites.
201 amy_site: "https://amy.software-carpentry.org/workshops"
202 dc_site: "http://datacarpentry.org"
203 swc_github: "https://github.com/swcarpentry"
204 swc_site: "https://software-carpentry.org"
205 swc_pages: "https://swcarpentry.github.io"
206 lc_site: "http://datacarpentry.org"
207 template_repo: "https://github.com/swcarpentry/styles"
208 example_repo: "https://github.com/swcarpentry/lesson-example"
209 example_site: "https://swcarpentry.github.com/lesson-example"
210 workshop_repo: "https://github.com/swcarpentry/workshop-template"
211 workshop_site: "https://swcarpentry.github.io/workshop-template"
212 training_site: "https://swcarpentry.github.io/instructor-training"
213
214 # Surveys.
215 pre_survey: "https://www.surveymonkey.com/r/swc_pre_workshop_v1?workshop_id="
216 post_survey: "https://www.surveymonkey.com/r/swc_post_workshop_v1?workshop_id="
217 training_post_survey: "https://www.surveymonkey.com/r/post-instructor-training"
218
219 # Start time in minutes (0 to be clock-independent, 540 to show a start at 09:00 am).
220 start_time: 0
221
222 # Specify that things in the episodes collection should be output.
223 collections:
224   episodes:
225     output: true
226     permalink: /:path/
227   extras:
228     output: true
229
230 # Set the default layout for things in the episodes collection.
231 defaults:
232   - values:
233       root: ..
234   - scope:
235       path: ""
236       type: episodes
237     values:
238       layout: episode
239
240 # Files and directories that are not to be copied.
241 exclude:
242   - Makefile
243   - bin
244
245 # Turn off built-in syntax highlighting.
246 highlighter: false
247 '''
248
249 ROOT_INDEX_MD = '''\
250 ---
251 layout: lesson
252 root: .
253 ---
254 FIXME: home page introduction
255
256 > ## Prerequisites
257 >
258 > FIXME
259 {: .prereq}
260 '''
261
262 ROOT_REFERENCE_MD = '''\
263 ---
264 layout: reference
265 permalink: /reference/
266 ---
267
268 ## Glossary
269
270 FIXME
271 '''
272
273 ROOT_SETUP_MD = '''\
274 ---
275 layout: page
276 title: Setup
277 permalink: /setup/
278 ---
279 FIXME
280 '''
281
282 EPISODES_INTRODUCTION_MD = '''\
283 ---
284 title: "Introduction"
285 teaching: 0
286 exercises: 0
287 questions:
288 - "Key question"
289 objectives:
290 - "First objective."
291 keypoints:
292 - "First key point."
293 ---
294 '''
295
296 EXTRAS_ABOUT_MD = '''\
297 ---
298 layout: page
299 title: About
300 permalink: /about/
301 ---
302 {% include carpentries.html %}
303 '''
304
305 EXTRAS_DISCUSS_MD = '''\
306 ---
307 layout: page
308 title: Discussion
309 permalink: /discuss/
310 ---
311 FIXME
312 '''
313
314 EXTRAS_FIGURES_MD = '''\
315 ---
316 layout: page
317 title: Figures
318 permalink: /figures/
319 ---
320 {% include all_figures.html %}
321 '''
322
323 EXTRAS_GUIDE_MD = '''\
324 ---
325 layout: page
326 title: "Instructor Notes"
327 permalink: /guide/
328 ---
329 FIXME
330 '''
331
332 INCLUDES_ALL_FIGURES_HTML = '''\
333 <!-- empty -->
334 '''
335
336 BOILERPLATE = (
337     ('AUTHORS', ROOT_AUTHORS),
338     ('CITATION', ROOT_CITATION),
339     ('CONTRIBUTING.md', ROOT_CONTRIBUTING_MD),
340     ('_config.yml', ROOT_CONFIG_YML),
341     ('index.md', ROOT_INDEX_MD),
342     ('reference.md', ROOT_REFERENCE_MD),
343     ('setup.md', ROOT_SETUP_MD),
344     ('_episodes/01-introduction.md', EPISODES_INTRODUCTION_MD),
345     ('_extras/about.md', EXTRAS_ABOUT_MD),
346     ('_extras/discuss.md', EXTRAS_DISCUSS_MD),
347     ('_extras/figures.md', EXTRAS_FIGURES_MD),
348     ('_extras/guide.md', EXTRAS_GUIDE_MD),
349     ('_includes/all_figures.html', INCLUDES_ALL_FIGURES_HTML)
350 )
351
352
353 def main():
354     """Check for collisions, then create."""
355
356     # Check.
357     errors = False
358     for (path, _) in BOILERPLATE:
359         if os.path.exists(path):
360             print('Warning: {0} already exists.'.format(path), file=sys.stderr)
361             errors = True
362     if errors:
363         print('**Exiting without creating files.**', file=sys.stderr)
364         sys.exit(1)
365
366     # Create.
367     for (path, content) in BOILERPLATE:
368         with open(path, 'w') as writer:
369             writer.write(content)
370
371
372 if __name__ == '__main__':
373     main()