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