Merge lp:~teknico/juju-gui/reformat-docs into lp:juju-gui/experimental

Proposed by Nicola Larosa
Status: Merged
Merged at revision: 318
Proposed branch: lp:~teknico/juju-gui/reformat-docs
Merge into: lp:juju-gui/experimental
Diff against target: 983 lines (+258/-245)
6 files modified
HACKING (+91/-93)
README (+2/-2)
docs/architecture.rst (+7/-7)
docs/conf.py (+12/-11)
docs/d3-component-framework.rst (+101/-91)
docs/process.rst (+45/-41)
To merge this branch: bzr merge lp:~teknico/juju-gui/reformat-docs
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+143154@code.launchpad.net

Description of the change

Reformat project docs.

Reformat the project documentation.

Sorry for the diff size. There are only formatting changes
in this branch, I moved the content changes to the next one.

https://codereview.appspot.com/7096056/

To post a comment you must log in.
Revision history for this message
Nicola Larosa (teknico) wrote :

Reviewers: mp+143154_code.launchpad.net,

Message:
Please take a look.

Description:
Reformat project docs.

Reformat the project documentation.

Sorry for the diff size. There are only formatting changes
in this branch, I moved the content changes to the next one.

https://code.launchpad.net/~teknico/juju-gui/reformat-docs/+merge/143154

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/7096056/

Affected files:
   M HACKING
   A [revision details]
   M docs/architecture.rst
   M docs/conf.py
   M docs/d3-component-framework.rst
   M docs/process.rst

Revision history for this message
Francesco Banconi (frankban) wrote :

Land as is.

See just a minor comment below.
Thanks for this documentation clean up, Nicola.
The resulting HTML looks nice.

https://codereview.appspot.com/7096056/diff/1/docs/d3-component-framework.rst
File docs/d3-component-framework.rst (right):

https://codereview.appspot.com/7096056/diff/1/docs/d3-component-framework.rst#newcode91
docs/d3-component-framework.rst:91: the event handlers in the various
modules. Render will not usually need to be
Maybe Render here should be written as ``render``?

https://codereview.appspot.com/7096056/

Revision history for this message
Nicola Larosa (teknico) wrote :

frankban wrote:
> docs/d3-component-framework.rst:91: the event handlers in the various
modules.
> Render will not usually need to be
> Maybe Render here should be written as ``render``?

I was not sure about it because of the uppercase R needed at the start
of the line, but maybe it should, yes.

https://codereview.appspot.com/7096056/

lp:~teknico/juju-gui/reformat-docs updated
318. By Nicola Larosa

Fixes as per reviews.

Revision history for this message
Nicola Larosa (teknico) wrote :

Please take a look.

https://codereview.appspot.com/7096056/diff/1/HACKING
File HACKING (right):

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode12
HACKING:12: You will need ``nodejs`` & ``npm`` from the PPA::
benji wrote:
> I don't understand the tendency to put literal quotes around so many
things, it
> seems like a lot of work for nothing. It appears popular in these
parts so I
> won't push the issue, but I am interested in the motivation(s).

I wanted those nouns to stand out a little, and the choice was between
NodeJS and ``nodejs``. I chose the latter because they appear monospace
in commands shortly after, but maybe it's not the best choice.

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode14
HACKING:14: sudo add-apt-repository ppa:chris-lea/node.js
benji wrote:
> Two reasons I like prefixing commands with a pseudo-prompt is that
[snip]

I like them too. I removed them because Jorge Castro asked me to remove
them from the charm README which appears on
https://jujucharms.com/~juju-gui/precise/juju-gui , and it seemed best
to maintain overall consistency in the documentation. But then again,
maybe not.

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode20
HACKING:20: sudo apt-get install imagemagick
benji wrote:
> There is a mixture of two- and four-space indents in this file. I
suspect we
> want one or the other. I lean slightly toward four-space indents.

Actually the indent for code/command samples is two-space all over the
docs. In this file there were a few three-space indents, fixed, thanks.

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode23
HACKING:23: integration, you may want to install JSHint globally in your
system::
benji wrote:
> Should "JSHint" be literal-quoted too?

Well, again, it's a choice between the proper name and the monospace
command, but you're right, we want to be somewhat consistent. :-)

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode104
HACKING:104: Running Unit Tests
benji wrote:
> This is tangential to any change you made, but I would like to suggest
that we
> consider standardizing on having two blank lines before section
headers in reST
> documents. I find that it makes the structure of the document stand
out much
> better. Much for the same reasons we use two newlines to separate the
> module-level elements in Python source.

Uhm. I see your point, I'm not sure I agree, though. The ReST markup for
section headers seem to create a good amount of whitespace already. But
I guess it's a matter of taste.

https://codereview.appspot.com/7096056/diff/1/HACKING#newcode152
HACKING:152: .. _`pertinent variable names`: `Potentially Useful
Release-Oriented Makefile Variables`_
benji wrote:
> I think this is a too-long line.

It is. Shortened.

https://codereview.appspot.com/7096056/

Revision history for this message
Nicola Larosa (teknico) wrote :
Revision history for this message
Nicola Larosa (teknico) wrote :

*** Submitted:

Reformat project docs.

Reformat the project documentation.

Sorry for the diff size. There are only formatting changes
in this branch, I moved the content changes to the next one.

R=frankban, benji
CC=
https://codereview.appspot.com/7096056

https://codereview.appspot.com/7096056/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'HACKING'
2--- HACKING 2013-01-03 16:13:25 +0000
3+++ HACKING 2013-01-15 14:41:23 +0000
4@@ -7,59 +7,58 @@
5 Developer Install
6 =================
7
8-Juju GUI uses nodejs based development tools.
9-
10-You'll need nodejs & npm from the ppa::
11-
12- $ sudo add-apt-repository ppa:chris-lea/node.js
13- $ sudo apt-get update
14- $ sudo apt-get install nodejs npm
15+Juju GUI uses nodejs-based development tools.
16+
17+You will need ``nodejs`` & ``npm`` from the PPA::
18+
19+ sudo add-apt-repository ppa:chris-lea/node.js
20+ sudo apt-get update
21+ sudo apt-get install nodejs npm
22
23 You also need ImageMagick::
24
25- $ sudo apt-get install imagemagick
26+ sudo apt-get install imagemagick
27
28 The linter will be installed locally per branch, but if you want editor
29-integration, you may want to install jshint globally in your system::
30-
31- $ sudo npm install -g jshint
32-
33-For building the docs, you also need sphinx::
34-
35- $ sudo apt-get install python-sphinx
36-
37-To make releases, you'll need pytz::
38-
39- $ sudo apt-get install python-tz
40-
41-The gui frontend can be installed and run with::
42-
43- $ bzr branch lp:juju-gui trunk
44- $ cd trunk
45- $ make prod
46+integration, you may want to install ``jshint`` globally in your system::
47+
48+ sudo npm install -g jshint
49+
50+For building the docs, you also need Sphinx::
51+
52+ sudo apt-get install python-sphinx
53+
54+To make releases, you will need PyTZ::
55+
56+ sudo apt-get install python-tz
57+
58+The Juju GUI can be installed and run with::
59+
60+ bzr branch lp:juju-gui trunk
61+ cd trunk
62+ make prod
63
64 It may take a while for the server to start the first time as npm will
65-need to download packages. When ready, the server will print:
66+need to download packages. When ready, the server will print::
67
68-Server listening on 8888
69+ Server listening on 8888
70
71 You can then access the GUI at <http://localhost:8888/>.
72
73-The front-end needs to talk to a Juju backend. So first you'll need
74+The front-end needs to talk to a Juju backend. So first you will need
75 to install Juju::
76
77- $ sudo apt-get install juju zookeeper
78-
79-Next you'll also need to deploy a juju environment with REST api access.
80-Currently that work resides in a pipeline of juju branches. The
81-recommended branch to use as a server is
82-``lp:~hazmat/juju/rapi-rollup``::
83-
84- $ bzr branch lp:~hazmat/juju/rapi-rollup
85-
86-You can use it with any environment, but for dev purposes, a local
87+ sudo apt-get install juju zookeeper
88+
89+Next you will also need to deploy a Juju environment with REST API access.
90+Currently that work resides in a pipeline of Juju branches. The
91+recommended branch to use as a server is ``rapi-rollup`` by hazmat::
92+
93+ bzr branch lp:~hazmat/juju/rapi-rollup
94+
95+You can use it with any environment, but for development purposes, a local
96 environment works well. One environment option specific to this branch
97-is the api-port. An appropriate sample configuration::
98+is the ``api-port``. An appropriate sample configuration::
99
100 default: dev
101 environments:
102@@ -71,17 +70,17 @@
103 juju-origin: ppa
104 api-port: 8081
105
106-Note that juju-origin is set to the ppa, the api server runs outside of
107-the container, and it is launched using whichever branch you're using.
108+Note that ``juju-origin`` is set to the PPA, the API server runs outside of
109+the container, and it is launched using whichever branch you are using.
110
111-Also note that the api-port should be set at 8081, which the gui's
112+Also note that the ``api-port`` should be set at 8081, which the GUI's
113 initial environment connection currently defaults to.
114
115-You'll need to bootstrap the local environment, and deploy one service.
116-The api server needs access to the provisioning credentials which are
117-lazily initialized in juju upon usage.
118+You will need to bootstrap the local environment, and deploy one service.
119+The API server needs access to the provisioning credentials which are
120+lazily initialized in Juju upon usage.
121
122-Juju-gui and rapi-rollup can communicate via an encrypted WebSockets
123+``Juju-gui`` and ``rapi-rollup`` can communicate via an encrypted WebSocket
124 connection: to enable it, add the following line to the config above::
125
126 api-secure: true
127@@ -89,38 +88,38 @@
128 You will also need to edit your ``app/config.js`` replacing
129 ``ws://localhost:8081/ws`` with ``wss://localhost:8081/ws``.
130
131-By default, rapi-rollup uses a self-signed certificate; because of that you
132-will need to visit the <https://localhost:8081/ws> WebSockets URL with your
133-browser and accept the included self-signed certificate, or the WebSockets
134+By default, ``rapi-rollup`` uses a self-signed certificate; because of that you
135+will need to visit the <https://localhost:8081/ws> WebSocket URL with your
136+browser and accept the included self-signed certificate, or the WebSocket
137 encrypted connection will not work.
138
139-In order to use a different certificate, you add an api-keys option to the
140+In order to use a different certificate you add an ``api-keys`` option to the
141 config above: its value will be the path of the directory containing the
142 certificate and the private key, whose filenames will have to be respectively
143 ``juju.crt`` and ``juju.key``.
144
145-After this, the gui should be functional (it automatically polls the
146-api server for establishing a websocket).
147+After this, the GUI should be functional (it automatically polls the
148+API server for establishing a websocket).
149
150 Running Unit Tests
151 ==================
152
153- $ make test-prod
154+ make test-prod
155
156 Running Lint
157 ============
158
159- $ sudo apt-get install python-virtualenv
160- $ make lint
161+ sudo apt-get install python-virtualenv
162+ make lint
163
164 API Documentation
165 =================
166
167-Generated JavaScript documentation is available in the yuidoc
168+Generated JavaScript documentation is available in the ``yuidoc``
169 directory. You can view the docs by running::
170
171- $ make yuidoc
172- $ xdg-open yuidoc/index.html
173+ make yuidoc
174+ xdg-open yuidoc/index.html
175
176 The `documentation <http://yui.github.com/yuidoc/syntax/>`_ for YUIDoc markup
177 is available.
178@@ -131,36 +130,35 @@
179 The project documentation is available in the ``docs/`` directory. It needs
180 Sphinx::
181
182- $ sudo apt-get install python-sphinx
183+ sudo apt-get install python-sphinx
184
185 Build the documentation::
186
187- $ make docs
188+ make docs
189
190 (This will also generate the above mentioned yuidoc documentation.)
191
192 View it::
193
194- $ xdg-open docs/_build/html/index.html
195+ xdg-open docs/_build/html/index.html
196
197 Making Releases
198 ===============
199
200-To make a release, you must either be in a checkout of lp:juju-gui
201+To make a release, you must either be in a checkout of ``lp:juju-gui``
202 without uncommitted changes, or you must override one of the
203 `pertinent variable names`_ to force a release.
204
205-.. _`pertinent variable names`: `Potentially Useful Release-Oriented Makefile Variables`_
206-
207-
208-To make the release tarball use:
209- $ make distfile
210-
211-In order to make and upload the release ('make dist'), you also need to have a
212-gpg key, and the python-pytz package installed (as well as launchpadlib, but
213-that is installed by default in Ubuntu).
214-
215-See the Process document (docs/process.rst) for step-by-step checklists to
216+.. _`pertinent variable names`:
217+ `Potentially Useful Release-Oriented Makefile Variables`_
218+
219+To make the release tarball use ``make distfile``.
220+
221+In order to make and upload the release (``make dist``), you also need to have
222+a GPG key, and the ``python-pytz`` package installed (as well as
223+``launchpadlib``, but that is installed by default in Ubuntu).
224+
225+See the Process document (``docs/process.rst``) for step-by-step checklists to
226 make developer and stable releases.
227
228 Potentially Useful Release-Oriented Makefile Variables
229@@ -168,45 +166,45 @@
230
231 The following is a list of pertinent Makefile variables.
232
233-FINAL
234- Set FINAL to any non-empty value to make a final release. This will cause
235- the bzr revno to be omitted from the tarball name, and (if you use the
236+``FINAL``
237+ Set ``FINAL`` to any non-empty value to make a final release. This will cause
238+ the ``bzr revno`` to be omitted from the tarball name, and (if you use the
239 release target) will cause the release to be uploaded to the stable series
240 rather than the trunk series. Example usage::
241
242- $ FINAL=1 make dist
243+ FINAL=1 make dist
244
245-PROD
246- By default, releases will be uploaded to staging.launchpad.net, which is a
247- separate version of Launchpad that uses a temporary database. This can be
248+``PROD``
249+ By default, releases will be uploaded to ``staging.launchpad.net``, which is
250+ a separate version of Launchpad that uses a temporary database. This can be
251 convenient for trying out the release process in the Makefile without
252- affecting our actual production releases. Set PROD to any non-empty value
253- to send uploads to launchpad.net, the production version of Launchpad, when
254- you are ready to make a real release.
255+ affecting our actual production releases. Set ``PROD`` to any non-empty
256+ value to send uploads to ``launchpad.net``, the production version of
257+ Launchpad, when you are ready to make a real release.
258
259 Note that you may need to ask the webops to turn off the two-factor
260 authentication on your Launchpad staging account in order for the staging to
261- work. Go to the #launchpad-ops channel on the Canonical IRC server and ask
262- something like "webops, could you disable 2FA on my staging account?"
263+ work. Go to the ``#launchpad-ops`` channel on the Canonical IRC server and
264+ ask something like "webops, could you disable 2FA on my staging account?".
265
266 Example usage::
267
268- $ PROD=1 make dist
269+ PROD=1 make dist
270
271-IS_TRUNK_BRANCH
272+``IS_TRUNK_BRANCH``
273 Set this to any non-empty value to force the Makefile to believe it is
274 working with a trunk checkout. Example usage::
275
276- $ IS_TRUNK_BRANCH=1 make dist
277+ IS_TRUNK_BRANCH=1 make dist
278
279-BRANCH_IS_CLEAN
280+``BRANCH_IS_CLEAN``
281 Set this to any non-empty value to force the Makefile to believe that the
282 current code tree has no changes. Example usage::
283
284- $ BRANCH_IS_CLEAN=1 make dist
285+ BRANCH_IS_CLEAN=1 make dist
286
287-BRANCH_IS_GOOD
288+``BRANCH_IS_GOOD``
289 Set this to any non-empty value to force the Makefile to bypass checks of
290- IS_TRUNK_BRANCH and BRANCH_IS_CLEAN. Example usage::
291+ ``IS_TRUNK_BRANCH`` and ``BRANCH_IS_CLEAN``. Example usage::
292
293- $ BRANCH_IS_GOOD=1 make dist
294+ BRANCH_IS_GOOD=1 make dist
295
296=== modified file 'README'
297--- README 2012-12-11 15:09:56 +0000
298+++ README 2013-01-15 14:41:23 +0000
299@@ -20,11 +20,11 @@
300 There are no official releases of Juju-GUI yet, so you have to get the source
301 code from Launchpad::
302
303- $ bzr branch lp:juju-gui
304+ bzr branch lp:juju-gui
305
306 The most useful available commands are shown by the command::
307
308- $ make help
309+ make help
310
311 You'll typically want to run one of ``make prod``, ``make debug`` or ``make
312 devel`` to deploy an environment. You might also run ``make test`` to check
313
314=== modified file 'docs/architecture.rst'
315--- docs/architecture.rst 2012-12-11 15:09:56 +0000
316+++ docs/architecture.rst 2013-01-15 14:41:23 +0000
317@@ -8,13 +8,13 @@
318 MVC YUI
319 -------
320
321-Juju-gui is based on yui's backbone style app framework. The `official docs
322+The Juju GUI is based on YUI's Backbone-style app framework. The `official docs
323 <http://yuilibrary.com/yui/docs/app/>`_ are highly recommended for developers.
324
325 An overview of the individual pieces.
326
327-- `Router <http://yuilibrary.com/yui/docs/router/>`_ - Route dispatch by url,
328- saves and restores url state.
329+- `Router <http://yuilibrary.com/yui/docs/router/>`_ - Route dispatch by URL,
330+ saves and restores URL state.
331
332 - `Views <http://yuilibrary.com/yui/docs/view/index.html>`_ - Rendering of a
333 view.
334@@ -26,7 +26,7 @@
335 Environment Integration
336 -----------------------
337
338-The gui connects and communicates to the environment over a web socket
339+The GUI connects and communicates to the environment over a WebSocket
340 connection.
341
342 RPC Calls
343@@ -38,7 +38,7 @@
344 RPC Events
345 ----------
346
347-Messages from the backend for known rpc operation results are messaged out as
348+Messages from the backend for known RPC operation results are messaged out as
349 Environment events.
350
351 Delta Stream
352@@ -66,11 +66,11 @@
353 -- delta
354
355 Questions
356----------
357+=========
358
359 - Model Composition and relations.
360
361-- relations by id
362+- Relations by id.
363
364 - We have multiple object states for a given.
365
366
367=== modified file 'docs/conf.py'
368--- docs/conf.py 2012-07-11 03:25:50 +0000
369+++ docs/conf.py 2013-01-15 14:41:23 +0000
370@@ -3,7 +3,8 @@
371 # JujuGUI documentation build configuration file, created by
372 # sphinx-quickstart on Tue Jul 10 23:15:46 2012.
373 #
374-# This file is execfile()d with the current directory set to its containing dir.
375+# This file is execfile()d with the current directory set to its containing
376+# directory.
377 #
378 # Note that not all possible configuration values are present in this
379 # autogenerated file.
380@@ -18,13 +19,13 @@
381 # documentation root, use os.path.abspath to make it absolute, like shown here.
382 #sys.path.insert(0, os.path.abspath('.'))
383
384-# -- General configuration -----------------------------------------------------
385+# -- General configuration ----------------------------------------------------
386
387 # If your documentation needs a minimal Sphinx version, state it here.
388 #needs_sphinx = '1.0'
389
390-# Add any Sphinx extension module names here, as strings. They can be extensions
391-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
392+# Add any Sphinx extension module names here, as strings. They can be
393+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
394 extensions = []
395
396 # Add any paths that contain templates here, relative to this directory.
397@@ -66,7 +67,7 @@
398 # directories to ignore when looking for source files.
399 exclude_patterns = ['_build']
400
401-# The reST default role (used for this markup: `text`) to use for all documents.
402+# The reST default role (used for this markup: `text`) for all documents.
403 #default_role = None
404
405 # If true, '()' will be appended to :func: etc. cross-reference text.
406@@ -87,7 +88,7 @@
407 #modindex_common_prefix = []
408
409
410-# -- Options for HTML output ---------------------------------------------------
411+# -- Options for HTML output --------------------------------------------------
412
413 # The theme to use for HTML and HTML Help pages. See the documentation for
414 # a list of builtin themes.
415@@ -167,7 +168,7 @@
416 htmlhelp_basename = 'JujuGUIdoc'
417
418
419-# -- Options for LaTeX output --------------------------------------------------
420+# -- Options for LaTeX output -------------------------------------------------
421
422 latex_elements = {
423 # The paper size ('letterpaper' or 'a4paper').
424@@ -180,8 +181,8 @@
425 #'preamble': '',
426 }
427
428-# Grouping the document tree into LaTeX files. List of tuples
429-# (source start file, target name, title, author, documentclass [howto/manual]).
430+# Grouping the document tree into LaTeX files. List of tuples (source
431+# start file, target name, title, author, documentclass [howto/manual]).
432 latex_documents = [
433 ('index', 'JujuGUI.tex', u'JujuGUI Documentation',
434 u'Juju GUI Developers', 'manual'),
435@@ -208,7 +209,7 @@
436 #latex_domain_indices = True
437
438
439-# -- Options for manual page output --------------------------------------------
440+# -- Options for manual page output -------------------------------------------
441
442 # One entry per manual page. List of tuples
443 # (source start file, name, description, authors, manual section).
444@@ -221,7 +222,7 @@
445 #man_show_urls = False
446
447
448-# -- Options for Texinfo output ------------------------------------------------
449+# -- Options for Texinfo output -----------------------------------------------
450
451 # Grouping the document tree into Texinfo files. List of tuples
452 # (source start file, target name, title, author,
453
454=== modified file 'docs/d3-component-framework.rst'
455--- docs/d3-component-framework.rst 2012-12-12 10:05:04 +0000
456+++ docs/d3-component-framework.rst 2013-01-15 14:41:23 +0000
457@@ -33,7 +33,7 @@
458 bindings allow the module to respond to both changes in its underlying data and
459 to changes in application state (through things like user interaction). It is
460 through these bound events that most rendering and interaction with the scene
461-are performed. Render becomes a rarely invoked complete redraw of the scene
462+are performed. Rendering becomes a rarely invoked complete redraw of the scene
463 while the modules themselves handle incremental updates via their event
464 handlers.
465
466@@ -46,53 +46,58 @@
467 are added options can be passed that will be made available in the Module's
468 run time. Modules added via the ``addModule`` method automatically have a
469 reference to the component via an YUI Attribute named ``component``, and any
470-options passed to the addModule call result in an Attribute called ``options``,
471-which will default to an empty object.
472+options passed to the ``addModule`` call result in an Attribute called
473+``options``, which will default to an empty object.
474
475 ::
476
477- comp = new Component();
478- comp.addModule(MyModule, {foo: bar})
479+ comp = new Component();
480+ comp.addModule(MyModule, {foo: bar})
481
482-This example would create a new component and, then using the MyModule
483+This example would create a new component and, then using the ``MyModule``
484 constructor, create an instance of this module (or use an instance if directly
485 passed) and set the ``component`` and ``options`` Attributes. In this example
486 the Module would have its ``foo`` option set to ``bar`` such that::
487
488- modInstance.get('options.foo') === 'bar'
489+ modInstance.get('options.foo') === 'bar'
490
491-where modInstance is the instance created by the above example's addModule call.
492+where ``modInstance`` is the instance created by the above example's
493+``addModule`` call.
494
495 Components then support rendering, which draws the scene described by any data
496-the modules reference. This is done in a number of phases. The first (and often
497-only) time ``render`` is called, a special ``renderOnce`` is called. This
498-allows the component to do any necessary setup work. Typically this will be to
499-create some svg element and retain a reference to it. In the context of
500-renderOnce, ``render`` will call ``update`` on each of its modules in the order
501-they were added. The ``update`` method is used to recalculate any intermediate
502-state associated with rendering the various data objects. This includes things
503-like position information. Once ``update`` has been called each module's
504-``render`` method is invoked. This performs the actual drawing work. It is at
505-this point that any d3js synthetic events are bound to the canvas (see the
506-section on events below). This separation of phases exists to make the life of
507-the Module writer simpler. They can rely on whatever elements they'll be drawing
508-(adding children to an svg object for example) will already have its container
509-properly available due to the renderOnce setup. They can also be sure that
510-any ``update`` driven intermediate data will be computed and available for
511-use in ``render``. This reduces the need for checks in each module to assert
512-the most basic DOM state.
513-
514-After the initial render its expected that updates to the scene occur via the
515-event handlers in the various modules. Render will not usually need to be called
516-more than once unless the entire Component rendering is removed from the DOM and
517-then later re-attached.
518-
519-The most important aspect of addModule (and its inverse removeModule) is that
520-they properly support adding and removing event listeners. When a component's
521-addModule method is triggered it will bind all the declarative events of the
522-module, and when removeModule is called it will properly clean up event
523-subscriptions. Properly defining and using events is the core of the component
524-system and this is described in its own section.
525+the modules reference. This is done in a number of phases.
526+
527+The first (and often only) time ``render`` is called, a special ``renderOnce``
528+is called. This allows the component to do any necessary setup work. Typically
529+this will be to create some SVG element and retain a reference to it.
530+
531+In the context of ``renderOnce``, ``render`` will call ``update`` on each of
532+its modules in the order they were added. The ``update`` method is used to
533+recalculate any intermediate state associated with rendering the various data
534+objects. This includes things like position information.
535+
536+Once ``update`` has been called, each module's ``render`` method is invoked.
537+This performs the actual drawing work. It is at this point that any D3
538+synthetic events are bound to the canvas (see the section on events below).
539+
540+This separation of phases exists to make the life of the Module writer simpler.
541+They can rely on whatever elements they'll be drawing (adding children to an
542+SVG object for example) will already have its container properly available due
543+to the ``renderOnce`` setup. They can also be sure that any ``update`` driven
544+intermediate data will be computed and available for use in ``render``. This
545+reduces the need for checks in each module to assert the most basic DOM state.
546+
547+After the initial render, it is expected that updates to the scene occur via
548+the event handlers in the various modules. ``render`` will not usually need to
549+be called more than once unless the entire Component rendering is removed from
550+the DOM and then later re-attached.
551+
552+The most important aspect of ``addModule`` (and its inverse ``removeModule``)
553+is that they properly support adding and removing event listeners. When a
554+component's addModule method is triggered, it will bind all the declarative
555+events of the module, and when ``removeModule`` is called it will properly
556+clean up event subscriptions. Properly defining and using events is the core
557+of the component system, and this is described in its own section.
558
559 As a final step, if the module has a ``componentBound`` callback it will be
560 invoked after successfully binding the module. This gives the module a
561@@ -102,19 +107,19 @@
562 Events
563 ======
564
565-The heart of the component system events can be defined in a number of ways and
566-understanding how to take advantage of the binding features will greatly aid in
567-producing a system which allows for clean, clear, well separated concerns and
568-which in turn supports incremental rendering and data updates.
569+Events are the heart of the component system, and can be defined in a number of
570+ways. Understanding how to take advantage of the binding features will greatly
571+aid in producing a system which allows for clean, clear, well separated
572+concerns, and which in turn supports incremental rendering and data updates.
573
574 There are three categories of events supported by the component framework. They
575 each have their purpose and share some common syntax around expression in the
576 module declaration, but a module writer must understand them all to properly use
577 the framework.
578
579-When modules are added three sets of declarative events are bound. This is done
580-by including in the module an events object with the following (each optional)
581-sections::
582+When modules are added, three sets of declarative events are bound. This is
583+done by including in the module an events object with the following (each
584+optional) sections::
585
586 events = {scene: {},
587 d3: {}
588@@ -125,8 +130,8 @@
589 delegation. This has advantages in that it scales well and these events can be
590 bound once to the top level container object of a component, and will work for
591 a DOM element matching its selector. Scene events are defined in one of two
592-ways: the first is a shorthand, the later is the more complete definition
593-(you'll see this in the other events types as well).
594+ways: the first is a shorthand, the second is the more complete definition
595+(you will see this in the other events types as well).
596
597 ::
598
599@@ -136,56 +141,61 @@
600
601 scene: {selector: function() {...}}
602
603-Though the string name of a callback is preferred, as this makes the whole
604+However, the string name of a callback is preferred, as this makes the whole
605 set of events more easily readable. The final form is::
606
607 scene: {selector: {callback: 'callbackName'}}
608
609-This expanded format is common to the other types of event declarations as
610+This expanded format is common to the other types of event declarations, as
611 well as supporting options available to the other types of bindings.
612
613-Regardless of form selector is a CSS selector, typically either a ``.class`` or
614-an ``#id`` though pseudo-selectors work as well. With scene events these
615-selectors are relative to whatever container was established on initialization
616-of the Component. A concrete example might be::
617+Regardless of form, ``selector`` is a CSS selector, typically either a
618+``.class`` or an ``#id``, though pseudo-selectors work as well. With scene
619+events, these selectors are relative to whatever container was established on
620+initialization of the Component. A concrete example might be::
621
622 scene: {'.person': {click: 'personClick'}}
623
624 Which says that whenever an object in the scene with a ``person`` class is
625-clicked, invoke the ``personClick`` handler. Handlers all have a common signature.
626-To understand the calling convention you must understand a bit about how D3
627-data bindings work. If you're not familiar with that, please read the D3
628-documents related to data binding. The short version is that each DOM element
629-can have data associated with it through D3's sophisticated data binding model.
630-In the YUI world it might be common that rendered DOM elements have D3 bound
631-data coming from a YUI App.Model. Knowing this we can understand the calling
632-convention::
633+clicked, invoke the ``personClick`` handler.
634+
635+Handlers all have a common signature. To understand the calling convention you
636+must understand a bit about how D3 data bindings work. If you're not familiar
637+with that, please read the D3 documents related to data binding.
638+
639+The short version is that each DOM element can have data associated with it
640+through D3's sophisticated data binding model. In the YUI world it might be
641+common that rendered DOM elements have D3 bound data coming from a YUI App
642+Model. Knowing this we can understand the calling convention::
643
644 callback(D3Data, component)
645- Where 'this' is the DOM element that triggered the selection
646- Any return is ignored.
647-
648-In the near future scene events will support an additional context attribute in
649-their handler definition which can either be ``component`` or ``module`` and will
650-default to module.
651+
652+Where ``this`` is the DOM element that triggered the selection. Any return is
653+ignored.
654+
655+In the near future, scene events will support an additional context attribute
656+in their handler definition which can either be ``component`` or ``module``,
657+and will default to module.
658
659 .. note::
660
661- At the time of this writing this is currently component and doesn't support
662- context selection. This is addressed in a branch and when landed this note
663- can be removed. It's worth noting now as the default will change.
664+ At the time of this writing this is currently ``component`` and does not
665+ support context selection. This is addressed in a branch, and when landed
666+ this note can be removed. It is worth noting now as the default will change.
667
668 The second type of event are D3 specific bindings. While declared in a style
669-similar to scene events, D3 events are bound after the modules render method is
670-triggered, as DOM elements must be present to be bound. There are very few cases
671-to prefer this style of event binding over normal scene events; however, there
672-are legitimate uses. If the event is a D3 synthetic event such as zoom or drag,
673-using D3 event bindings make sense as these cannot be delegated to using scene
674-events. The second case we are aware of at the time of this writing is that
675-certain mouse events are dealt with more easily using D3 events, as D3 uses a
676-well documented system of x, y position coordinates which the mouse events map
677-cleanly. This is a possible area for future expansion both in terms of cleaner
678-mouse handling and creating a possible mapping of D3 synthetics to YUI custom
679+similar to scene events, D3 events are bound after the module's ``render``
680+method is triggered, as DOM elements must be present to be bound. There are
681+very few cases to prefer this style of event binding over normal scene events;
682+however, there are legitimate uses.
683+
684+If the event is a D3 synthetic event such as zoom or drag, using D3 event
685+bindings make sense as these cannot be delegated to using scene events. The
686+second case we are aware of at the time of this writing is that certain mouse
687+events are dealt with more easily using D3 events, as D3 uses a well documented
688+system of x, y position coordinates which the mouse events map cleanly. This
689+is a possible area for future expansion both in terms of cleaner mouse
690+handling and creating a possible mapping of D3 synthetics to YUI custom
691 events. An example of D3 events follows::
692
693 d3: {dragstart: 'beginDrag',
694@@ -195,22 +205,22 @@
695 The calling convention is as above::
696
697 callback(D3Data, component)
698- 'this' is the DOMElement triggering the event.
699- Return value is ignored.
700-
701-The final type of event is called ``yui`` events. This classification doesn't
702+
703+``this`` is the DOMElement triggering the event. Return value is ignored.
704+
705+The final type of event is called ``yui`` events. This classification does not
706 depend on DOM selection or delegation, and is designed to provide simple
707 handling; its use case is YUI custom events. A common pattern for
708 usage might be to emit events of interest (or possible interest) from one
709 module and listen for those events in another. By subscribing to custom events
710-across modules, it's reasonably easy to extend functionality with only a loose
711+across modules, it is reasonably easy to extend functionality with only a loose
712 coupling of the modules themselves (through event names only as an example).
713
714 YUI events are defined similarly to the others but differ in some key ways.
715-First, they don't depend on a DOM selector, they depend on a YUI styled event
716+First, they do not depend on a DOM selector, they depend on a YUI styled event
717 name (prefixed or otherwise). Secondly, they support a traditional YUI notion
718-of event phases: ``before``, ``on`` and ``after``. For additional details on how those
719-work, refer to the YUI event docs.
720+of event phases: ``before``, ``on`` and ``after``. For additional details on
721+how those work, refer to the YUI event docs.
722
723 ::
724
725@@ -222,11 +232,11 @@
726
727 In this example another module might fire a ``cancelAction`` event; our module
728 wants to respond to this by closing its menu before the triggering event is
729-handled, and the context (this) of the callback should be this module.
730+handled, and the context (``this``) of the callback should be this module.
731
732-Context can either be ``component`` or ``module``, with module being the default
733-``this`` for handlers. Phase can be ``before``, ``on``, or ``after``, with ``on`` being
734-the default.
735+Context can either be ``component`` or ``module``, with module being the
736+default ``this`` for handlers. Phase can be ``before``, ``on``, or ``after``,
737+with ``on`` being the default.
738
739 Complete Example
740 ================
741
742=== modified file 'docs/process.rst'
743--- docs/process.rst 2013-01-03 14:53:18 +0000
744+++ docs/process.rst 2013-01-15 14:41:23 +0000
745@@ -5,17 +5,17 @@
746 Checklist for Starting a Branch
747 ===============================
748
749-- Understand the problem. If you don't, ask and be persistent until you do.
750+- Understand the problem. If you do not, ask and be persistent until you do.
751 - When determining a solution, consider this preferred `Software
752 Architecture Cheat Sheet
753- <http://gorban.org/post/32873465932/software-architecture-cheat-sheet>`_
754+ <http://gorban.org/post/32873465932/software-architecture-cheat-sheet>`_.
755 - Have a pre-implementation call with someone about your solution. If you
756 are not sure of your solution, prototype before the pre-implementation call.
757 - Use TDD. Your prototype might be perfect, but you can still move it aside
758 and rebuild it gradually as you add tests. It can go quickly.
759-- Update the CHANGES.yaml file with your changes. The newest (topmost)
760- section should have the version "unreleased". If not and you are
761- making changes, add an "unreleased" section at the top. All other
762+- Update the ``CHANGES.yaml`` file with your changes. The newest (topmost)
763+ section should have the version ``unreleased``. If not and you are
764+ making changes, add an ``unreleased`` section at the top. All other
765 version numbers follow `Semantic Versioning <http://semver.org/>`_.
766
767 Checklist for Preparing for a Review
768@@ -26,7 +26,7 @@
769 - Pre-review your diff! Tip: you can diff your branch against a local
770 trunk named "trunk" with "bzr diff -r ancestor:../trunk/".
771
772- - All new code should have tests. If it doesn't, be prepared to explain
773+ - All new code should have tests. If it does not, be prepared to explain
774 why to skeptical reviewers.
775 - Have you cleaned out temporary comments and debugging changes?
776 - Is the code understandable?
777@@ -35,24 +35,24 @@
778 - Run tests! Someday we'll have that in the lbox hook...
779
780 - Make sure there is a bug for your branch. Ideally there was one when you
781- started, but if not, see the "-new-bug" option to "lbox propose".
782+ started, but if not, see the ``-new-bug`` option to ``lbox propose``.
783 - Aim for a branch diff size between 300 and 500 lines.
784 - Treat branch diff sizes of more than 800 lines as a problem.
785
786- - Try to subdivide it now. If you can't, explain to your reviewers your
787+ - Try to subdivide it now. If you cannot, explain to your reviewers your
788 reasoning.
789 - Treat this as an opportunity to learn. Consider what you could have
790 done differently.
791
792-- Update the CHANGES.yaml file with a description of the changes you
793+- Update the ``CHANGES.yaml`` file with a description of the changes you
794 made. Reference Launchpad bugs if appropriate.
795 - If the branch is very minor, such as a documentation change, feel free to
796 self-review. However, *don't neglect to consider your responsibilities
797 above*, especially the diff review and running tests (even if you think
798- there's no way the tests could have been affected).
799+ there is no way the tests could have been affected).
800
801 It is your responsibility to get reviewers of your branch! Reviewers will
802-hopefully take it, but if they don't, rustle some up.
803+hopefully take it, but if they do not, rustle some up.
804
805 When you get your reviews back, be appreciative, and be sure to respond to
806 every request, even if it is to disagree.
807@@ -70,11 +70,11 @@
808 <http://goo.gl/DBDtJ>`_.
809
810 - Run ``make test-prod`` and ``make test-debug`` and confirm that tests pass.
811-- Run ``python improv.py -f sample.json`` in the rapi-rollup juju branch, and
812- run ``make server`` with the juju-ui branch.
813+- Run ``python improv.py -f sample.json`` in the ``rapi-rollup`` Juju branch,
814+ and run ``make server`` with the ``juju-ui`` branch.
815
816- * Don't forget to clear the browser cache: index.html may be sticking around
817- because of the cache.manifest.
818+ * Do not forget to clear the browser cache: ``index.html`` may be sticking
819+ around because of the cache.manifest.
820 * Verify that the browser reports no 404s and no Javascript errors in the
821 console.
822 * QA the changes if possible, exploring different use cases (and edge cases).
823@@ -85,21 +85,21 @@
824 - Review the diff, including notes from the above as appropriate.
825
826 * Make sure that new code has tests.
827- * Make sure user-facing changes are described in CHANGES.yaml.
828+ * Make sure user-facing changes are described in ``CHANGES.yaml``.
829 * Make sure you can understand the new code. Ask for clarification if
830 necessary.
831 * Consider the advice in this preferred `Software Architecture Cheat Sheet
832 <http://gorban.org/post/32873465932/software-architecture-cheat-sheet>`_
833 * Make sure changes to a file correspond to the naming conventions and other
834 stylistic considerations local to that file, and within our project.
835- * Before you ask for a change, think and make sure you can't compromise
836+ * Before you ask for a change, think and make sure you cannot compromise
837 reasonably with the coder. If there is a low importance disagreement, in
838 general the coder's position should win.
839
840 - In your summary message, thank the coder.
841 - In your summary message, if you ask for changes, make it clear whether you
842 want to re-review after the changes, or if you automatically approve if the
843- changes are made. We've agreed to use these arbitrary code phrases, for
844+ changes are made. We have agreed to use these arbitrary code phrases, for
845 clarity: "Land as is," "Land with changes," and "Request review".
846
847 Checklist for Making a Stable Release
848@@ -108,13 +108,13 @@
849 - Get a clean branch of the trunk:: ``bzr branch lp:juju-gui``.
850 - If you are using a pre-existing branch, make sure it is up-to-date:
851 ``bzr pull``.
852-- Verify that the top-most version in CHANGES.yaml specifies the expected
853+- Verify that the top-most version in ``CHANGES.yaml`` specifies the expected
854 version string. It should be bigger than the most recent version found on
855- https://launchpad.net/juju-gui/stable . If the most recent version string
856- is "unreleased," do the following.
857+ <https://launchpad.net/juju-gui/stable>. If the most recent version string
858+ is ``unreleased``, do the following.
859
860- * Decide what the next version number should be (see http://semver.org/) and
861- change "unreleased" to that value.
862+ * Decide what the next version number should be (see <http://semver.org/>)
863+ and change ``unreleased`` to that value.
864 * Commit to the branch with this checkin message:
865 ``bzr commit -m 'Set version for release.'``
866 * Push the branch directly to the parent (``bzr push :parent`` should work).
867@@ -126,7 +126,8 @@
868 - In an empty temporary directory somewhere else on your system, expand the
869 tarball: ``tar xvzf PATH_TO_TARBALL``
870 - While still in the directory where you extracted the tar file, change to the
871- build-prod directory and start a server: ``python -m SimpleHTTPServer 8888``.
872+ ``build-prod`` directory and start a server: ``python -m SimpleHTTPServer
873+ 8888``.
874 - In Chrome and Firefox, QA the application. At the very least, load the app,
875 open the charm panel, go to an inner page, and make sure there are no 404s
876 or Javascript errors in the console. We want a real QA script for the
877@@ -139,19 +140,19 @@
878
879 * Note that you may need to ask the webops to turn off the two-factor
880 authentication on your Launchpad staging account in order for this to
881- work. Go to the #launchpad-ops channel on the Canonical IRC server and ask
882- something like "webops, could you disable 2FA on my staging account?"
883+ work. Go to the ``#launchpad-ops`` channel on the Canonical IRC server and
884+ ask something like "webops, could you disable 2FA on my staging account?"
885 * When Launchpad asks you what level of permissions to grant, assuming you
886 are running on your own computer that you manage securely, the easiest
887 thing to do is hopefully also reasonably safe: accept that the computer
888 may perform all actions, indefinitely.
889
890-- Go to https://staging.launchpad.net/juju-gui/stable and verify that you see
891+- Go to <https://staging.launchpad.net/juju-gui/stable> and verify that you see
892 a new release and a new download file.
893 - Download the file, expand it in a temporary directory, run ``python -m
894 SimpleHTTPServer 8888``, and do a quick double-check in the browser that it
895- is what you expect. Looking at juju-ui/version.js should also show you the
896- version you expect.
897+ is what you expect. Looking at ``juju-ui/version.js`` should also show you
898+ the version you expect.
899 - This is a final release. Consider asking others to verify the package on
900 staging.
901 - Now it is time for the actual, real release. Head back to your branch and
902@@ -164,12 +165,13 @@
903 is done in production will in many cases eventually be copied over to
904 staging, but never vice versa. Staging data is destroyed periodically.
905
906-- Go to https://launchpad.net/juju-gui/stable and verify that you see
907+- Go to <https://launchpad.net/juju-gui/stable> and verify that you see
908 a new release and a new download file.
909
910 - Set the version back to ``unreleased`` by doing the following.
911
912- * Restore ``- unreleased:`` as most recent version string in CHANGES.yaml.
913+ * Restore ``- unreleased:`` as most recent version string in
914+ ``CHANGES.yaml``.
915 * Commit to the branch with this checkin message:
916 ``bzr commit -m 'Set version back to unreleased.'``
917 * Push the branch directly to the parent (``bzr push :parent`` should work).
918@@ -182,7 +184,7 @@
919 - Get a clean branch of the trunk:: ``bzr branch lp:juju-gui``.
920 - If you are using a pre-existing branch, make sure it is up-to-date:
921 ``bzr pull``.
922-- Verify that the top-most version in CHANGES.yaml is "unreleased."
923+- Verify that the top-most version in ``CHANGES.yaml`` is ``unreleased``.
924 - Run ``bzr revno``. The revno should be bigger than the most recent release
925 found on `Launchpad <https://launchpad.net/juju-gui/trunk>`_.
926 - Run the tests and verify they pass: ``make test-prod`` and then
927@@ -192,9 +194,11 @@
928 - In an empty temporary directory somewhere else on your system, expand the
929 tarball: ``tar xvzf PATH_TO_TARBALL``.
930 - Looking at ``build-prod/juju-ui/version.js`` should show you a version string
931- that combines the value in the branch's CHANGES.yaml with the branch's revno.
932+ that combines the value in the branch's ``CHANGES.yaml`` with the branch's
933+ revno.
934 - While still in the directory where you extracted the tar file, change to the
935- build-prod directory and start a server: ``python -m SimpleHTTPServer 8888``.
936+ ``build-prod`` directory and start a server: ``python -m SimpleHTTPServer
937+ 8888``.
938 - In Chrome and Firefox, QA the application. At the very least, load the app,
939 open the charm panel, go to an inner page, and make sure there are no 404s
940 or Javascript errors in the console. We want a real QA script for the
941@@ -207,19 +211,19 @@
942
943 * Note that you may need to ask the webops to turn off the two-factor
944 authentication on your Launchpad staging account in order for this to
945- work. Go to the #launchpad-ops channel on the Canonical IRC server and ask
946- something like "webops, could you disable 2FA on my staging account?"
947+ work. Go to the ``#launchpad-ops`` channel on the Canonical IRC server and
948+ ask something like "webops, could you disable 2FA on my staging account?"
949 * When Launchpad asks you what level of permissions to grant, assuming you
950 are running on your own computer that you manage securely, the easiest
951 thing to do is hopefully also reasonably safe: accept that the computer
952 may perform all actions, indefinitely.
953
954-- Go to https://staging.launchpad.net/juju-gui/trunk and verify that you see
955+- Go to <https://staging.launchpad.net/juju-gui/trunk> and verify that you see
956 a new release and a new download file.
957 - Download the file, expand it in a temporary directory, run ``python -m
958 SimpleHTTPServer 8888``, and do a quick double-check in the browser that it
959- is what you expect. Looking at juju-ui/version.js should also show you the
960- version you expect, as seen in the similar earlier step above.
961+ is what you expect. Looking at ``juju-ui/version.js`` should also show you
962+ the version you expect, as seen in the similar earlier step above.
963 - Now it is time for the actual, real release. Head back to your branch and
964 run ``PROD=1 make dist``. The computer will again walk you through the
965 process.
966@@ -230,7 +234,7 @@
967 is done in production will in many cases eventually be copied over to
968 staging, but never vice versa. Staging data is destroyed periodically.
969
970-- Go to https://launchpad.net/juju-gui/trunk and verify that you see
971+- Go to <https://launchpad.net/juju-gui/trunk> and verify that you see
972 a new release and a new download file.
973
974 You are done!
975@@ -244,7 +248,7 @@
976 Where bzr may have provided information such as the revno, sensible defaults
977 are used instead. As many of these bzr commands are used to populate
978 variables regardless of the target, defining NO_BZR will have an effect on
979-all targets, except dist, which will refuse to complete.
980+all targets, except ``dist``, which will refuse to complete.
981
982 - Note that this allows one to run any make target from the working copy,
983 even if it is a lightweight checkout, by skipping steps that involve

Subscribers

People subscribed via source and target branches