Good Documentation – some musings

A ‘speed is better than perfection’ philosophy might be applied to many areas of life, but documentation is not one of them. Unfortunately the standard of documentation needed so that 90% of people can follow it is, well, 90% perfect.

It actually doesnt take all that much longer to write good documentation once you sit back and think for a moment about what it was like when you had to perform the task for the first time yourself. Its no coincidence that much of the better documentation written on this site comes from things the documenter just recently found out how to do.

Documentation doesnt have to be austere, the tone can be warm and conversational, especially if the user is not all that au fait with computers.

However the most important things are still the obvious ones: check after each sentence and see if if you have relayed to the user exactly what he needs to do (and where to find things – screenshots can be of enormous help) and lastly, get your completely computer illiterate auntie/uncle/person-dragged-in-off-the-street to try using your documentation!

Two directives: sidebar and figure pt.2

Sidebars

We recently covered the use here of two very handy features of reStructured Text (reST): namely the sidebar and figure directives. Sidebars and figures are very useful features for adding additional content styles to documents using reST, for example web diaries created using the EasyBlog product…

As demonstrated in this very article, a sidebar is an area for highlighted content which floats to the right of the actual article. The code for a sidebar in reST is as follows:

.. sidebar:: Sidebar Title
   :subtitle: Optional Sidebar Subtitle

   The sidebar content text would go here.

   .. image:: image.jpg (an optional image)

Those who would like their sidebars to float to the left or middle are out of luck—it’s to the right only for reasons of taste and aesthetics.

And for those interested in such things, the sidebar directive makes use of the following CSS:

.documentContent .sidebar {
       float: right;
       margin: 0 0 10px 20px;
       padding: 15px;
       width: 250px;
       border: &dtml-borderWidth; &dtml-borderStyle; &dtml-globalBorderColor;;
       overflow: hidden;
       }

.documentContent p.sidebar-title {
       font: normal 150%/150% <dtml-var headingFontFamily> !important;;
       background-color: &dtml-globalBackgroundColor;;
       padding: 4px 15px 2px 15px;
       margin: -15px -15px 10px -15px;
       border-bottom: <dtml-var globalBorderColor> solid 1px;
       }

p.sidebar-subtitle {
       font: normal 110%/110% <dtml-var fontFamily> !important;;
       padding: 0;
       margin: 0 0 4px 0;
       }

.documentContent .sidebar img {
       border: none !important;;
       }

#vs-scheme1 .documentContent p.sidebar-title, #vs-scheme1 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme1;;
       }

#vs-scheme2 .documentContent p.sidebar-title, #vs-scheme2 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme2;;
       }

#vs-scheme3 .documentContent p.sidebar-title, #vs-scheme3 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme3;;
       }

#vs-scheme4 .documentContent p.sidebar-title, #vs-scheme4 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme4;;
       }

#vs-scheme5 .documentContent p.sidebar-title, #vs-scheme5 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme5;;
       }

#vs-scheme6 .documentContent p.sidebar-title, #vs-scheme6 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme6;;
       }

#vs-scheme7 .documentContent p.sidebar-title, #vs-scheme7 .documentContent p.sidebar-subtitle {
       color: &dtml-vsScheme7;;
       }

Close observers of the above will note there are several optional dtml calls in this CSS. The dtml in this particular example is designed to work in conjunction with the vsCore product default stylesheet, alongside ploneDefault base_properties.doc, both of which we have modified to create customisable portal_tab colours. The dtml above acquires the colour values of the portal_tab active in a particular location, changing the sidebar title and subtitle colour to match. The sidebar would of course work equally well with a single "hard-wired" title and subtitle colour value for an entire site.

Figure floats

float-left

Floated to the left.

CSS styles have also been created to combine image float styles with the figure directive. There are now three CSS classes which can be applied to the figure directive: float-right, float-left, and float-centre, and what they do should be fairly self-evident—floating an image to the right, left and centre respectively. Keen observers of CSS will point out that there is no such thing as a float-centre command, which is quite correct, but in this case it seemed more consistent to name the class "float-centre" for the sake of users.

float-right

Floated to the right.

While the reST figure directive has always allowed a caption to be added along with an image, with a little additional CSS trickery the captions here have not only been styled with a little font-sizing and colour, but have also been positioned in a more aesthetically pleasing way at the bottom left corner of the images, without using the depracated align="left" html tag, which is the default method in reST.

float-centre

Floated to the centre.

The reST code for these styles is as follows:

.. figure:: image.jpg
   :alt: float-left
   :figclass: float-left

   An image floated to the left.

.. figure:: image.jpg
   :alt: float-right
   :figclass: float-right

   An image floated to the right

.. figure:: image.jpg
   :alt: float-centre
   :figclass: float-centre

   An image floated to the centre

And the CSS employed is as follows:

.float-right {
     position: relative;
     float: right;
     text-align: left;
     border: &dtml-borderWidth; &dtml-borderStyle; &dtml-globalBorderColor;;
     margin: 0 0 23px 20px;
     padding: 0;
     clear: right;
     }

.float-left {
     position: relative;
     float: left;
     text-align: left;
     border: &dtml-borderWidth; &dtml-borderStyle; &dtml-globalBorderColor;;
     margin: 0 20px 23px 0;
     padding: 0;
     clear: left;
     }

.float-centre {
     position: relative;
     text-align: center;
     border: none;
     margin: 0 0 23px 0;
     padding: 0;
     clear: both;
     }

.documentContent .float-right p.caption, .documentContent .float-left p.caption {
     margin: 0 0 -18px 0;
     padding: 3px 0 0 0;
     bottom: 0;
     left: 0;
     font: normal 11px/13px Arial, Helvetica, sans-serif !important;;
     color: #000;
     }

.documentContent .float-centre p.caption {
     margin: 3px 0 0 0;
     padding: 0;
     font: normal 11px/13px Arial, Helvetica, sans-serif !important;;
     color: #000;
     }

Note that a small amount of dtml is again used to style the images with the border colour, width and style, as defined in the site base_properties doc—thereby matching the border around your floated images with the style of your portlets etc. Of course it may be more appropriate in some cases to hardwire this value.

Also of note is the fact that the floated-centre image doesn’t have a border, for the reason that without a fixed width defined the image container is via the block properties of CSS defaulting to 100% width, giving you a border that expands to the full width of your content column no matter the size of the image. Should there be a way to get the border to match the size of the image (the CSS attributes display, width and margin: auto were of no avail) the class will be updated to have a border.

Error reporting and screenshots

Here is a very good article on bug reporting, discovered by Atmasamarpan:

http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

It certainly helped me sympathise with poor developers and curb my linguistic excesses when reporting problems.

Whenever possible, screenshots really help to pinpoint the problem by making the developer or Plone admin see what you’re seeing. Below are some instructions for screenshots for both Windows and Mac…..

1. Windows

You can capture the screen and paste it into any graphics program: by pressing the ‘print screen button’ (up there somewhere to the right of F12). This appears to do nothing when you press it, but the screen is then stored in memory. One can then open any graphics program like Photoshop or even Microsoft Paint and paste in the image. (For Photoshop one should first create a new document)

If you dont want to save the whole screen, pressing ‘Alt’ and ‘Print Screen’ together will capture only the window you have open.

This is a slightly clumsy way to do it; there are freeware programs out there which do the job much quicker (and which personally I’m happy enough with, for example MWSnap) but I understand the words ‘windows’ + ‘freeware’ together can be enough to send a chill up the stoutest of spines……

2. Mac

The keyboard shortcuts are:

Apple-Shift-3: Capture the entire screen
Apple-Shift-4: Capture a self-selected portion of the screen
Apple-Shift-4 then Space: Capture a window

Both options automatically create an image for you named "Picture 1.png" on your desktop.

There is also an application named "Grab" in the Utilities folder which allows screen captures with more options. Grabs features can also be accessed from the "File" menu within the application Preview.

Further in-depth information on screen captures in Mac OSX 10.4 can be found here: http://www.macworld.com/weblogs/macgems/2005/09/tigerscreenshots/index.php

(thanks to John-Paul for the info)

More unearthed tips….

Again from my email clear out, I have found a few more tips, this time suggested by Priyadarshan…..

Drag and drop item reordering in Plone 2.5

You can just reorder the order items have in a folder just by dragging and dropping them around. This is of course of great usefulness, since the order in a folder dictates the order in the navigation.

Making a static copy of a Plone Site

This is an excellent recipe to make a static copy of a Plone site:
http://www.zopelabs.com/cookbook/1103609775

Searching for Code in Google

http://www.google.com/codesearch allows searches for source code
on the web. Allows filtering for programming language, license etc.

Plone Navigation and Google Images

I was cleaning out my mail account today and discovered this rather interesting tip from Richard which he divulged to me decades ago…if you want to boost the standing of an image on your Plone site in Google Images, one way would be to make images viewable in navigation (via preferences -> navigation settings).

This is by no means an aesthetic solution; however you can always use workflow to filter out images you do and don’t want displayed in navigation.

Polaroid effect using css and reST

Those who are not familiar restructured text may initially bemoan it’s lack of power and flexibility when compared to XHTML, but as often the case in life, initial appearances can be deceiving.

Although the use of CSS for styling and presentation is "best practice" in XHTML, it is not yet mandatory, which allows anyone with knowledge of such "deprecated" tags as "align=center" or "font", to illegally wreck havoc with your beautiful CMS-based site.

Outside of a mandatory 2 month course in basic XHTML and CSS, one solution which desperate webmasters have often deployed is to force site editors and contributors to work with WYSIWYG editors configured to strip out any and all illegal tags. Not only is this a somewhat draconian solution, and immensely frustrating from a user point of view, but it still doesn’t bring your site any closer to being beautifully or correctly formatted. Just not illegally so.

And don’t get me started on tables…

Restructured text on the other hand forces compliance to XHTML best practise precisely because it is not XHTML. By allowing users to work in an environment much closer to the simple text notepad which almost everybody is familiar with, and without a single (more often than not forgotten) tag in sight, the simplicity of ReST leaves the site contributor the concentrate on content, as God would have intended it, and takes care of the parsing of said content into strict XHTML for them.

But that’s not all. Presentation is still possible via CSS—also as God intends it—yet much to the relief of the site designer and webmaster—outside of the control of a user whose obsession with "beautifying" one little plant can be to the detriment of the wellbeing of the entire garden.

And not just the presentation of your basic paragraph and heading tags, but, watching closely, the ReST figure directive, which in combination with a little CSS jiggery-pokery detailed below is capable of deploying some quite remarkable effects.

The Polaroid Effect

Through deployment solely of the class "float-right-360" to the figure directive below, it is possible to add a polaroid effect to a photograph in the following manner:

As reStructuredText:

.. figure:: /images/the_moon.jpg
   :alt: the moon
   :figclass: float-right-360

    The moon during a lunar-eclipse. Pretty!

To produce the following image and caption:

the moon

The moon during a lunar-eclipse. Pretty!

Which is achieved with the following css:

.float-right-360 {
       position: relative;
       float: right;
       text-align: left;
       background-image: url(polaroid_360_270.png);
       background-repeat: no-repeat;
       margin: 10px 0 10px 20px;
       padding: 1px 8px 8px 1px;
       border: none;
       }

.float-right-360 img {
       border: #fff 7px solid;
       border-bottom: #fff 36px solid;
       width: 247px;
       height: 308px;
       }

.float-right-360 p.caption {
       position: absolute;
       font: normal 11px/13px Arial, Helvetica, sans-serif !important;;
       color: #000;
       margin: 0;
       padding: 0 10px 0 0;
       top: 321px;
       left: 10px;
       }

Note there is one limitation to this effect—the image used must be exactly 308px H by 247px W, because there simply aren’t enough "hooks" inside the figure directive to deploy the necessary number of background images to allow scaling.

As a work around to this limitation, one could create a variety of classes for pre-determined image sizes and orientations, which would also have the added benefit of forcing your users to stick to creating images in sizes complimentary to the overall site design.

Which raises another sore point about CMS’s which don’t employ image-sizing engines—but that would be another topic…

Editing old pages in reSt

One problem with changing from HTML (or a content editor) to reStructured Text in Plone is that the text editor doesnt convert your old HTML docs to reStructured Text.

However, my experience so far is that if you copy the text of the page (not the code), click on the edit tab, delete the HTML code and paste the content of the page back in, it does a pretty good job of keeping the layout of the page. Paragraphs, bullet points and numbered lists are largely mantained. Of course, links images and preformatted text all have to be put back, but what can you do…

Creating proper internal links

Images

Images are the same: .. image:: /images/vasudevaserver.gif

This is bad: /images/vasudevaserver.gif/

The bottom line is: Never add a trailing slash!

Also, please make sure images always have the type of file at the end (.jpg or .gif)

vasudevaserver