M204wiki style guide: Difference between revisions
Line 11: | Line 11: | ||
For example, if you enter <code><nowiki>''Model204''</nowiki></code> or <code><i>Model 204</i></code>, you're doing something wrong. You <strong>should</strong> enter <code><var class="product">Model 204</var></code>. Even if you're trying to emphasize something, like the "should" in the last sentence, you should use <code><strong>should</strong></code> not <code><nowiki>'''should'''</nowiki></code> or <code><b>should</b></code> though, admittedly, <code><strong></code> doesn't tell one a heck of a lot about the semantics of the enclosed word or words. | For example, if you enter <code><nowiki>''Model204''</nowiki></code> or <code><i>Model 204</i></code>, you're doing something wrong. You <strong>should</strong> enter <code><var class="product">Model 204</var></code>. Even if you're trying to emphasize something, like the "should" in the last sentence, you should use <code><strong>should</strong></code> not <code><nowiki>'''should'''</nowiki></code> or <code><b>should</b></code> though, admittedly, <code><strong></code> doesn't tell one a heck of a lot about the semantics of the enclosed word or words. | ||
== | ==Headings== | ||
The outermost headers on any page should be level two headers so should have two equals sign on either side: | The outermost headers on any page should be level two headers so should have two equals sign on either side: | ||
<p class="code"><nowiki>==This is a header==</nowiki> | <p class="code"><nowiki>==This is a header==</nowiki> |
Revision as of 20:52, 11 March 2013
Overview
While the most important part of a wiki is the content, following a few simple rules in formatting wiki documentation pages can make it easier for people to use the wiki because the consistent look and feel of each page. In addition, following these rules can make it easier to write the pages as standard use of wiki and HTML tags makes it possible to convey information in the format of the text rather than having to state it explicitly.
Use of HTML tags and attributes that focus on the semantics of text also has some advantages:
- It's easier to remember semantic tags and attributes than remembering the physical display characteristics of a certain kinds of text.
- It's easier for Sirius to tweak or customize the look and feel of text based on its semantics if the semantics of the text is explicit in the markup.
In fact, as a general rule of thumb, if you're coding any explicit physical text attributes in your wiki markup, it's probably a sign that you're doing something wrong or that Sirius needs to expand its list of semantic classes.
For example, if you enter ''Model204''
or <i>Model 204</i>
, you're doing something wrong. You should enter <var class="product">Model 204</var>
. Even if you're trying to emphasize something, like the "should" in the last sentence, you should use <strong>should</strong>
not '''should'''
or <b>should</b>
though, admittedly, <strong>
doesn't tell one a heck of a lot about the semantics of the enclosed word or words.
Headings
The outermost headers on any page should be level two headers so should have two equals sign on either side:
==This is a header==
Links
For cross-references (links) to an article/page, your markup can simply be the exact article title enclosed in pairs of left and right brackets. To link to the article entitled "My target page":
[[My target page]]
If you want the text of the link that the viewer sees to be different from the page title, append to the page name a vertical bar (|) followed by the text you want displayed:
[[My target page|My special link text]]
In the wiki page view, the above markup displays as:
The link text above is colored red to remind that this page has yet to be created. For more information anout creating a page, see Help:Starting a new page.
For links to a section on a page, where the section is an h2- through h6-level heading, thus automatically indexed by the wiki code,
follow the page title as above by #sectionName
, where sectionName is the exact heading title. Then append to the section name a vertical bar followed by the text you want displayed, enclosed in double-quotation marks:
[[My target page#My section|"My section"]]
In the wiki page view, the above markup displays as:
Using the quotation marks is arbitrary, but it is the style used in this wiki.
For more information about formatting variations of the above types of links as well as other kinds of links, including external links, those to a target outside of the wiki, see Help:Links
Syntax diagrams
One of the most common documentation structures is syntax diagrams. Syntax diagrams show the format of a command, statement, or method invocation. While in an ideal world there would be a nice macro language for specifying the key elements of a syntax diagrams, we don't live in an ideal world so most of work of indicating syntax must be done manually.
The first rule of syntax diagrams is that they must be contained inside a <p>
element with a class of syntax
:
<p class="syntax"> ... syntax diagram goes here </p>
There are other rules that must be observed:
- All keywords that must be typed literally as in the syntax diagram must start with an upper case character.
- All syntax terms that are not literals should start with lower case letters.
- Camel case should be used for artifical compound word such as, for example,
veryImportantParameter
. Of course, keywords can also use this kind of captilization but, because keywords must begin with upper case characters, the casing is, strictly speaking, referred to as Pascal case. - Optional words or phrases must be inside of square brackets. These can be nested if, for example, an optional keyword appears inside an optional clause. Note that for Callable methods, the target (including the equal sign) should be inside square brackets. Note also that, strictly speaking, the syntax diagram for functions is not really correct as a function can be used in a context where its result is not assigned to a variable, but the standard syntax diagram shows an assignment to a variable. It's not obvious how we can make the syntax diagram more accurate without losing information or making it needlessly complex.
- Similary, methods can apply to variables or the results of expressions. This dichotomy can be expressed by not using the percent sign in the syntax term for the method object (nor for parameters). This "rule" is currently not followed everywhere — some places use the percent sign at the start of syntax terms that might be variables or results of expressions and some don't. For now, the recommendation is that the percent sign be used only where a percent variable is required. Perhaps, some day, this will turn into a rule.
- The standard Model 204 continuation character dash (
-
) should be used to continue each line where the syntax is continued on the next line. While more than 90% of the time, syntax diagrams will refer to a single line statement or a command, it's still good discipline to stick with this rule so multi-line syntax is obvious.
Because syntax diagrams should be inside a <p> element, rather than, say, a <pre> element, wiki markup is allowed inside the block. The most useful wiki markup in a syntax diagram is a link, usually to a section that provides more detail about a word or phrase. For example, if there is a syntax term in a syntax diagram called eve
, and a section called All about eve
, a syntax diagram might be coded as follows:
<p class="syntax">object:foo([[All about eve|eve]]) </p>
Note that in the above example, the syntax diagram starts on the same line as the <p class="syntax">
tag. This is because starting the syntax diagram on the following line results in an extra, unnecessary blank line at the top of the box that contains the syntax diagram in the output wiki page. There is no known work-around for this.
It is generally a good idea to try to get the terms in a syntax diagram to line up "nicely" if the diagram extends beyond one line. Obviously, "nicely" is a term that leaves a lot of room for interpretation but, since <p class="syntax">
blocks are always displayed in a monospace font, it shouldn't be a daunting task to make words in multiple lines line up for readability. There are also no guidelines for the width of syntax diagram lines, but making lines too long can result in them running off the end of the page or becoming difficult to scan because of the number of characters on a single line.
Examples
Code examples are much like syntax diagrams but use the code class, like this:
<p class="code"> ... for %x from 1 to %myStringList:Count if %myStringList(%x):subString(1,3) eq ':h2' then printText this is a header: {%myStringlist(%x)} end if end for ... </p>
Categories and Lists
Sirius has avoided the use of third-party add-on modules to MediaWiki in order to make it easy for sites to take local copies of M204wiki material without having to validate and install extra software.
Unfortunately, that leaves out a few useful features, like Dynamic Page Lists (DPL) which make up for some of the shortcomings of the default MediaWiki "Category" technology. Our compromise has been to use both MediaWiki categories and to create hand-built 'list' pages, buttressed by by some User Language consistency checks.
The standard MediaWiki category page is less informative, but updates itself (nearly) automatically. The hand-built list is at risk of being out of date, but it is also more useful as a quick cheat sheet for a set of related methods or functions.
For some category/list sets, such as the big table on "List of $functions" and the tables on the "$Function set" on the top of that page, we have some User Language (here, FUNSCHECK.WIKI) which we should run regularly to ensure all is well.
Other cases may not yet have had the User Language built but should be straightforward, for example, the List of JANUS WEB subcommands and the JANUS WEB subcommands category page.
Some will be harder, such as the hand-built "List of Fast/Unload $functions", because there is no category for it specifically. It is all of the $function entries in the Fast/Unload User Language Interface, and once we convert that page to a hand-built list (with its *CHECK.WIKI!) then the Fast/Unload $function list should be checkable.
PDFs of the contents of Category pages
Most Category pages have a link to create a PDF file that contains all the categories on the page. That PDF will also include any Subcategory entries on the page if the MediaWiki link that placed the subcategory items onto the Category:Commands page is appropriately edited on the "home Category page" of those subcategories. This is also true for the sidebar link "PDF of this page."
For example, the "Operator commands" subcategory on the "Category:Commands" page is ordinarily the result of a [[Category:Commands]]
tag on the "Operator commands" page source. If that markup is changed to [[Category:Commands| Operator commands]]
(note space before "Operator"), the "Operator commands" subcategory on the "Category:Commands" page will display as before and in the same position except without a bold "O" heading for items that begin with the letter "O". If the other subcategories on the "Category:Commands" page are similarly edited, PDFs of the "Category:Commands" page will include the subcategories.
See also
- We feel that the formatting/etc. is good on the method pages.
- For more editing information, see MediaWiki's Help page.