You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

It's well-known that a consistent user interface is easier to use. Consistency helps users focus on the task rather than the user interface. Likewise, a consistent documentation style helps users focus on the information, rather than the formatting.

A related goal is to design the documentation so that it is easy to maintain, so that it remains internally consistent with the framework itself.

Change Happens

Anyone who has worked with databases knows the value of normalizing the schema. Ideally, we want to store each fact exactly once, and then use query system to retrieve that fact whereever it is needed. If we store a fact once, we only need to update it once, and we avoid inconsistencies in our data set.

To the extent possible, we want to "normalize" our technical documentation. Like a database, all technical documentation is subject to change. When change happens, we want the documentation to be as easy to update as possible. One way to do that is to try and minimize redudency (without sacrificing ease of use).

Single sourcing with snippets

The "holy grail" of technical documentation is single sourcing. One way we try to single-source documentation is to pull content directly from the Javadocs and source code into the documentation.

Using a snippet macro, we are able to tag portions of the Javadocs and source code for reuse. The macro fetches those snippets from the repository and merges the conntent into the documentation.

Use the Source!

Before writing any new content, ask yourself if we could place the content in the repository in either one of the example applications or the Javadocs. Rather than contrive an example, can you pull a snippet from one of the applications? Rather than reiterate Javadoc, could we update the Javadoc and make it a snippet?

Here are some examples of the snippet macro in action:

{snippet:id=description|javadoc=true|url=com.opensymphony.xwork.interceptor.LoggingInterceptor}

or

{snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork.interceptor.LoggingInterceptor}

or

{snippet:id=sitegraph-usage|lang=none|url=webwork/src/java/com/opensymphony/webwork/sitegraph/sitegraph-usage.txt}

or

{snippet:id=ajax-validation-example|lang=xml|url=webwork/webapps/ajax/src/webapp/lesson1/example.jsp}

Legend:

id

The name of the snippet (required).

url

The URL where the snippet can be found (required).

lang

The language that the code block. If this snippet is simply text, don't include this parameter and the content will be printed outside of a code block.

javadoc

If true, the content is within a Javadoc block. If this is set to true, then the preceeding "* " (asterisk-space) characters will be stripped before merging the content. Also, the content is assumed to be already HTML escaped and won't be escaped again.

All snippets are marked off by the pattern START SNIPPET: XXX and END SNIPPET: XXX where XXX is the name of the snippet that is assigned in the id attribute of the macro. The URL is typically a location that points to the project's source control contents.

About URLs

As you probably noticed in the examples, there are several formats for URL patterns. A fully-qualified URL is always allowed, though that is often not practical. We've customized the macro to be a bit more intelligent with the URL attribute.

About snippet markers

When possible, all snippet markers should be in comment blocks. How they are commented depends on where the snippet is being embedded.

Commenting HTML or XML snippets
<!-- START SNIPPET: xxx -->
...
<!-- END SNIPPET: xxx -->
Commenting snippets in Java code
if (true != false) {
    // START SNIPPET: xxx
    System.out.println("This is some silly code!");
    // END SNIPPET: xxx
}

If the snippet is embedded in Javadocs, use HTML comments as they won't render in the Javadocs. For XML examples in Javadocs can be tricky. (See Timer Interceptor for an example.). Javadocs want to use the <pre> tag, but you don't want that tag in the snipped content.

One technique is to embed the snippet markers inside the <pre> tag.

Snipping XML examples from Javadoc content
* <pre>
 * <!-- START SNIPPET: example -->
 * &lt;!-- records only the action's execution time --&gt;
 * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
 *     &lt;interceptor-ref name="completeStack"/&gt;
 *     &lt;interceptor-ref name="timer"/&gt;
 *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
 * &lt;/action&gt;
 * <!-- END SNIPPET: example -->

About Headings

(info) This section refers to: Notation Guide >> Headings.

About h1

Don't use h1. at the top of each page. The page title serves as the "top level header". This is not as obvious online, but it is very apparent when the documentation is exported to HTML or PDF.

Try to start each page with some introductory text, to separate the page title from the rest of content.

Likewise, try to have some content between all page headings. Avoid placing headings one after the other.

Document sections

Headings can help you divide your document in sections, subsections, sub-subsections and so forth.

Advantages

Your document becomes more organized.

Disadvantages

If you exaggerate you could fragment your text too much.

Here we go again!

This segment an example of overusing headings. This whole "Headings" section has suo few paragraphs that it really should have been written in just one section. The "advantages" and "disadvantages" would be just as easy to render as a table.

Headings capitalization

Try to use intial capitals for h1 and h2 headers.

For h3 and smaller headings, try to capitalize only the first word, and any proper nouns.

By using different capilazation sytles, we emphasize the importance of bigger headings.

Avoid skipping headers

The headers form an outline for the page. It is not good practice to skip outline levels, and it is not a good practice to skip heading levels either. Try not to skip from a h2 to a h4.

Too many headings?

If you find yourself writting too many h2 headings in a single page, consider breaking the page into child pages.

General punctuation and grammar

Good online resources for punctuation, grammar, and text style include

In print, two excellent (and inexpensive!) resources are

More on Text Effects

(star) This section refers to: Notation Guide >> Text Effects.

Text effects should be largely used, although I have some questions on some of them. Strong, emphasis, and inserted can be used to denote important parts of a sentence. But I really think inserted should have been called underline in the notation guide. I don't see the point of using deleted, since when someone changes a page and deletes stuff, Confluence keeps the old versions in history.

I can't think of a situation in our documentation for superscript and subscript, but it doesn't hurt to mention them. I can't say anything about %span% because I frankly don't know what it does. Monospaced is heavily used, for instance, to refer to webwork-default.xml file or items in source code examples: <xmltag />, JavaClass or javaVariable.

Boxes vs. Block Quotes

I think boxes and block quotes do the same job, but boxes are better. Therefore, I suggest we don't use block quotes.

Aren't info boxes neat? Aren't them all neat? By now you may have realized I think we should definetly use them...

Colors should be used in very specific cases, or else each documentation writers would color his/her pages the way he/she thinks it's better, and it would look like a mess. One such specific case in which colors can help is when you want them to work as tags or captions. For (a lame) example, in this paragraph, guidelines are in red and justifications are in blue. Yes, it's a really really lame example, I know. (smile)

Text Breaks

(star) This section refers to: Notation Guide >> Text Breaks.

Text breaks shouldn't be used. If you'd like paragraphs or headings to have more spacing (before or after), the style sheet should be changed, not the contents. Patrick explained this a long time ago. Other stuff in this section (paragraphs, horizontal ruler, — symbol and – symbol) can be used when necessary.

(star) This section refers to: Notation Guide >> Links.

All types of links can and should be used. I already used a few in this document. Just watch out for links to non-existing pages when writing on the official documentation.

Lists

(star) This section refers to: Notation Guide >> Lists.

Lists can be used for many purposes. Every time we list some things that are in order, ordered lists are used. If they don't have a specific order, unordered lists are the case. List should be nested if needed for a better organization. Unordered lists should be created only with the * (star) notation only, so all pages use the same style of bullet.

  • This is an unordered list in star notation;
  • Items can have sub-items
    • That can have sub-items
      • That can have sub-items...
        • What is the limit?
  • Mixing ordered and unordered lists is possible:
    1. One;
    2. Two;
    3. Three.

      List indentation

      Use tabs to indent nested lists. This way your page's markup is more readable and easier to maintain.

Images and Icons

(star) This section refers to: Notation Guide >> Images and Notation Guide >> Misc.

External images should be used only when strictly necessary (meaning, don't use images as list bullets or box icons). Also, try to use only images that are very unlikely to be removed from its current URL, to reduce document maintenance. Pay attention on copyright issues too! Attached images are less prone to become missing links, however, we should not clutter the documentation with unnecessary attachments and copyrights are also a issue here.

Example:

Icons are cool in a number of situations. Some of them, such as (info), (plus), (lightbulb) or (star) can make the documentation look professional, but some others, such as (smile) and (thumbs up) may give a feeling of amateurship and I wouldn't advise them for pages that are exported to form the official documentation.

Tables

(star) This section refers to: Notation Guide >> Tables.

Tables are very useful when lists just don't do it. Meaning: don't write a table when a list suffices. Tables are more organized, because you can align the text in columns. Since the markup text for tables in confluence is not very easy to read, remember complex and big tables are very hard to maintain.

The table below was copied from a reference page on WebWork's configuration (just the first two lines were copied). This is an example where tables are good: a list wouldn't be as organized as this table to display these files and their properties.

File

Optional

Location (relative to webapp)

Purpose

web.xml

no

/WEB-INF/

Web deployment descriptor to include all necessary WebWork components

action.xml

no

/WEB-INF/classes/

Main configuration, contains result/view types, action mappings, interceptors, etc

Advanced Formatting

(star) This section refers to: Notation Guide >> Advanced Formatting.

I've already made my point about info, warning, tip and note boxes. Other interesting markups are noformat and code. The former can be used for general purpose text while the latter is used to display example source code, be it HTML, XML, Java or anything that is part of a software solution. When displaying something that has a name, use a title, as the example below demonstrates.

HelloWorld.java
/** Hello World class. */
public class HelloWorld {
  /** Main method. */
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

A typical example of noformat would be the command line statements to compile and run the code above. We should also standardize terminal notation ({$} for command prompt).

$ javac HelloWorld.java

$ java HelloWorld
Hello, World!

Do not use tabs inside noformat and code, use two spaces instead. This way your code is indented but keeps lines short. Large lines should be splitted as to fit in a 800x600 resolution screen without horizontal scroll bars.

Your Comments Please

Please contribute to this page. Let me know if you have a different opinion on something (please justify it). Please warn me if I wrote something wrong or if this proposed Style Guide is missing something. Feel free to correct my english, since I'm not a native speaker.

  • No labels