root / PyCon07 / slides.txt

Revision 78:b5dabe9762d1, 13.1 kB (checked in by Tarek Ziad?? <tarek@…>, 16 months ago)

rupy slides, starting up

Line 
1==============
2PYCon Tutorial
3==============
4
5How to document an open source Project ?
6
7<tarek@ziade.org>
8
9.. contents:
10
11How am I ?
12==========
13
14- Python developer since 2000
15
16- Core developer in Nuxeo CPS (Zope) for 3 years
17
18- Involved in Zope sprints
19
20- Author of a french book "Programmation Python" (Eyrolles, 2006)
21
22- Creator of AFPY (french speaking PUG)
23
24- CTO at Emencia, for a Python e-commerce framework
25
26
27What are the goals of this tutorial ?
28=====================================
29
30- Understand the place of documentation in software projects
31
32- Learn a few patterns to document your project
33
34- Practice them !
35
36How this tutorial is organized ?
37================================
38
39- Each part comes with:
40
41 - a few slides
42 - exercises *you* do.
43
44The plan
45========
46
47- A few definitions
48- Part 1: Writing a document
49- Part 2: Writing documents for Python
50- BREAK - Yepeee
51- Part 3: Using documents for TDD
52- Part 4: Writing documents for a Python project
53- LUNCH - Yeeahhaa
54
55A few definitions
56=================
57
58What kind of documentation are we talking about ?
59
60A few definitions
61=================
62
63Technical documentation that helps to understand how a codebase
64works and how it can be used.
65
66This can be:
67
68- a document describing a package, a module or a serie of package
69- a glossary
70- a tutorial
71- a recipe
72
73A few definitions
74=================
75
76What is the use and who is the target ?
77
78A few definitions
79=================
80
81- Project developers, to...
82
83  - build a shared knowledge
84  - improve code quality
85
86- Community, to...
87
88  - facilitate participation (e.g. non developers)
89  - facilitate adoption and comprehension
90
91Part 1
92======
93
94Part 1 - Writing a document
95
96This part is composed of three sections:
97
98- Mastering reStructuredText
99- Writing techniques ans tips: the seven laws
100- Team writing
101
102Mastering reSTructuredText
103==========================
104
105reSTructuredText is
106
107- a plaintext markup syntax and parser system
108- easy to read as-is, yet powerful
109- the Pythonistas laTeX
110
111Mastering reSTructuredText
112==========================
113
114- example (Tarek, switch on)
115- cheatsheet
116- see http://docutils.sf.net
117
118Mastering reSTructuredText
119==========================
120
121|smile| let's do exercise #1 and #2
122
123Mastering reSTructuredText
124==========================
125
126reST can be:
127
128- used for all documentation needs
129
130- manipulated like code (versioning, etc.)
131
132- easily transformed into various shapes
133
134Python developers |love| reST
135
136Writing techniques and tips
137===========================
138
139The seven *laws* for technical writing:
140
141- Two-step writing process
142- Simple style
143- Targeted readership
144- Focused information
145- Realistic examples
146- "Light but sufficient" approach
147- Structured documents
148
149The Two-step writing process
150============================
151
152Writing should be done in two stages (Elbow, 1980):
153
154- a free writing where ideas are written on the paper no matter the shape.
155- a review stage where things are structured and reviewed.
156
157Each stage should take 50% of the time.
158
159|important| Split you writing time in two phases, no one can write it right
160the first time (except Mozart)
161
162Simple style
163============
164
165- Use short sentences and simple writing style.
166
167- Use simple vocabulary
168
169Targeted readership
170===================
171
172Focus on your target when you write a document (RÃŒping, 2003).
173
174Assume their background knowledge to restrict the scope of the documentation.
175
176|important| A *prerequest* section can help a lot.
177
178Focused information
179===================
180
181A document is about a clear focus.
182
183A precise title for each section and the document itself, and a summary
184can help.
185
186|important| If you cannot easily name the document or one of its section,
187there's a problem
188
189Realistic examples
190==================
191
192Drop the *foo* and *bar* habits. Examples must be real-life examples:
193
194Neh::
195
196    >>> from package import graph
197    >>> foo = graph.calculateSquare(1, 1, 1, 1)
198    >>> bar = graph.renderSquare(foo)
199
200Better::
201
202    >>> from package import graph
203    >>> square = graph.calculateSquare(1, 7, 1, 10)
204    >>> square_view = graph.renderSquare(square)
205
206"Light but sufficient" approach
207===============================
208
209A working software is more important than the best documentation in the world
210(Ambler, 2002).
211
212*Quality over Quantity* is the best rule.
213
214|important| Spending too much time to find something in the documentation is
215a bad sign.
216
217|important| Think documents like code. Always limit the size of its sections,
218examples, etc.
219
220|wink| Modularized documentation is the key.
221
222Structured documents
223====================
224
225Use a clear document portfolio to facilitate the reading. Document should
226use:
227
228- an abstract with a readers guideline
229- a toc when there are more than one section
230- references
231- glossary
232- tables and diagrams
233
234|important| Never write a document that doesn't have a template
235
236Writing techniques and tips
237===========================
238
239Distribution of tipsheet, let's do exercise #3, and apply the laws |smile|
240
241Team writing
242============
243
244Pair-writing ensures:
245
246- understandable documents
247- increased and homogeneous quality
248
249|important| The best pair is made with the end-user
250
251|important| Each document should have a champion, though.
252
253Team writing
254============
255
256Let's do exercise #4 to feel it |glasses|
257
258Topic ideas:
259
260    - cooking recipe
261    - how to play a board or card game
262    - how to fish shrimps
263
264
265Writing a document
266==================
267
268Conclusions for Part 1:
269
270- reST is perfect to write documents
271- Anyone can write good documentation, with the seven laws in mind
272- Team writing provides to documents what pair-programming provides to code
273
274Pause
275=====
276
277
278.. figure:: media/sleeping.jpg
279   :alt: Sleeper
280   :align: center
281   :height: 350
282   :width: 450
283
284   Developer that does not practice documentation
285
286Pause
287=====
288
289.. figure:: media/winner.png
290   :alt: Winner
291   :align: center
292   :height: 350
293   :width: 250
294
295   Developer that write documentation (=winner)
296
297Part 2
298======
299
300Part 2 - Writing documents in Python
301
302This part specializes the documenting process to Python software
303
304Writing documents in Python
305===========================
306
307Python projects are organized into:
308
309- code: classes, functions
310- module
311- package
312- groups of package (let's call it a *bundle*)
313
314Documenting code
315================
316
317The code is documented with:
318
319- inline comments
320- functions, classes and modules docstrings
321
322Inline comments
323===============
324
325- the less, the best
326- needed only if code is not self-explanatory
327- used for local design notes (XXX, TODO and friends)
328
329Functions, classes and modules
330==============================
331
332- a function or method docstring should be composed of
333    - a single, short sentence
334    - an extra text when needed
335    - sometimes, explanation on in and out variables
336
337- classes and module docstrings resumes the role of each element
338
339|important| read PEP8 and PEP256
340
341Documenting modules
342===================
343
344- Let's create a text file for each important module in a package
345
346- The text file describes what the module does
347
348- example: utils.txt and utils.py
349
350- Let's practice: exercise #5 |glasses|
351
352
353Documenting a package
354=====================
355
356A package comes with a few mandatory files:
357
358- **README.txt**: a global file that presents the package
359- **LICENCE** or **COPYING**: the licence used
360- **CHANGELOG**: Lists of changes for each version of the package
361- **INSTALL.txt**: how to install the package
362- **TODO.txt**: Lists all things to do (sometimes replaced with a
363  link to a tracker or a website in README.txt)
364
365Documenting a package
366=====================
367
368A package comes with a few mandatory folders:
369
370- doc: collects all documentation file, except README.txt
371- tests: contains unit and functional tests
372
373Documenting a package
374=====================
375
376Let's add mandatory files to `pycommunity` (exercise #6)
377
378Using documents for Test-Driven Development (TDD)
379=================================================
380
381- Tests can be added within documents
382
383- They look like prompt sessions
384
385- example: doctest.txt
386
387Using documents for TDD
388=======================
389
390Let's call it *DDD* (Documentation-Driven Development)
391
392Why should you use DDD ? |smile|
393
394Using documents for TDD
395=======================
396
397How is managed documentation in projects, most of the time ?
398
399Using documents for TDD
400=======================
401
402.. figure:: media/classical_cycle.jpg
403   :alt: Sleeper
404   :align: center
405
406Using documents for TDD
407=======================
408
409|sad| fast obsolescence of documentation
410
411|sad| you need to fight with developers so they write doc
412
413|sad| your project website is always obsolete
414
415Using documents for TDD
416=======================
417
418What brings DDD to projects ?
419
420Using documents for TDD
421=======================
422
423.. figure:: media/ddd_cycle.jpg
424   :alt: Sleeper
425   :align: center
426
427
428*(fruit may vary depending on the season)*
429
430Using documents for TDD
431=======================
432
433|smile| A big part of the documentation is growing together with code
434
435|smile| developers use documentation to write code (and they |love| it)
436
437|smile| your project website upgrades can be partly automated
438
439Doctesting
440==========
441
442Let's doctest
443
444Doctesting
445==========
446
447|important| A doctest is still a document: do not drawn it with test fixtures
448
449|important| The doctest shows usage examples of the **public** code
450
451|important| The unit tests tests everything else
452
453|wink| Keep your doctests code blocks short and simple
454
455Doctesting
456==========
457
458|glasses| Let's practice with exercise #8
459
460Writing documents in Python
461===========================
462
463Conclusion for Part 2:
464
465- There's 3 level of documentation:
466
467  - inline comments
468  - docstrings
469  - separated docstrings
470- Packages comes with mandatory documentation
471- We can do TDD with doctests, and deal with doc. like code
472
473Pause
474=====
475
476.. figure:: media/magnum.jpg
477   :alt: "Doctests are so cool" -- Magnum
478   :align: center
479   :height: 300
480   :width: 400
481
482   "Doctests are so cool" -- Magnum
483
484Part 3
485======
486
487Part 3 - Writing document for Python Projects
488
489This part is composed of four sections:
490
491- Overview
492- Writing tutorials
493- Writing cookbook and recipes
494- Writing a glossary
495
496Writing document for Python Projects
497====================================
498
499- Python projects are *bundles*
500- *bundles* have high level documentation:
501
502  - Tutorials
503  - Recipes, gathered in a cookbook
504  - a Glossary
505
506Tutorial
507========
508
509A tutorial is a very high-level document that explains a functionality of a
510bundle, how to use it or to change it.
511
512Tutorial
513========
514
515A tutorial...
516
517- ..should not contain any code, or very little
518
519- ..makes a heavy use of diagrams, tables
520
521- ..should be understandable by non-developers
522
523- ..need to focus on a single topic, regardless the number of
524  packages involved.
525
526- ..should be less than 8000 signs e.g. two screens
527
528Tutorial
529========
530
531Possible template:
532
533- title & abstract (two sentences max)
534- prerequest: level needed, other documents to read
535- toc (when # sections > 1)
536- body
537- references
538- a list of other tutorials to take on next
539  (*a graph of tutorials can make a good tutorials listing*)
540
541Tutorial
542========
543
544|glasses| let's do exercise 9
545
546Recipes
547=======
548
549- Recipes are the technical parts of tutorials.
550
551- A recipe answer to one question, that should be its title.
552
553- Each question is linked to the sentences founded in tutorials.
554
555- A recipe is short (2 screens)
556
557Recipes
558=======
559
560Examples:
561
562- How to code a RSS view ?
563- How to extract the content of a web page ?
564
565Recipes
566=======
567
568Possible template:
569
570- title & abstract (two sentences max)
571- prerequest: level needed, other documents to read
572- toc (when # sections > 1)
573- body
574- references
575- a list of related recipes
576
577Recipes
578=======
579
580Let's do exercice 10: "How to use ConfigParser"
581
582Glossary
583========
584
585A glossary builds a shared knowledge by helping to..
586
587- ..avoid using two terms for the same definition
588- ..removes approximacies in documents:
589    not sure on how to explain a concept with simple words ?
590    look in the glossary |wink|
591
592Glossary
593========
594
595|important| If I remove all terms founded in the glossary from tutorials,
596they should be made of plain english.
597
598Linking everything
599==================
600
601- A tutorial links to recipes.
602
603- Tutorials and recipes makes heavy use of the glossary
604
605- A bundle is fully documented with:
606
607  - tutorials
608  - recipes
609  - modules doctests
610  - inline comments and doctests
611
612PyCommunity
613===========
614
615A tool that:
616
617- reads a bundle
618
619- extract its documentation
620
621- generates a website with it
622
623- is not released yet (soon |wink|)
624
625PyCommunity
626===========
627
628- can be hooked in the subversion post-commit hook
629
630- can be configured to inject its generated page in an existing site
631
632|smile| let's try it #exercise 11
633
634Conclusions
635===========
636
637- Using `DDD` is a good way to enhance the QA
638
639- It is enjoyed by most developers
640
641- It increases both writing and programming skills
642
643The end
644=======
645
646- Thank you !
647
648- Questions ? Answers ?
649
650References
651==========
652
653Useful books:
654
655- "Writing with Power" - Peter Elbow
656- "Agile Documentation" - Andreas RÃŒping
657
658Useful websites:
659
660- http://emenciacommerce.com/en: Emencia Commerce Suite - My company software
661- http://tarekziade.wordpress.com : My blog
662
663Incoming Events
664===============
665
666You all go to Rupy in Poznan, Polan, 14/15 April |wink|
667
668.. |wink| image:: media/wink.png
669.. |smile| image:: media/smile.png
670.. |important| image:: media/important.png
671.. |love| image:: media/love.png
672.. |glasses| image:: media/glasses.png
673.. |sad| image:: media/sad.png
674
Note: See TracBrowser for help on using the browser.