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