HOWTO: Style Guide
How to format various portions of tutorials, mainly how to format code samples, system commands, and interactive python sessions.
Code Samples
Code samples should be as easy to read and understand as possible. The code should also be easy to copy-and-paste into an actual .py file. Fortunately, these are both easy to accomplish using Plone.A code sample is below. If you're using the Epoz editor, you can make the pretty blue box by selecting the code, then choosing "Formatted" from the drop-down style menu. You can make the comments green to make them easier to read with the "Text Color" button.
# Import modules
import cdms, vcs, os, sys
# Open data file
filepath = os.path.join(sys.prefix, 'sample_data/clt.nc')
cdmsfile = cdms.open(filepath)
cdmsfile.listvariables()
data = cdmsfile('clt')
# Initialize VCS
v = vcs.init()
# Plot data using the default boxfill graphics method
v.plot(data)
Inline Code
To highlight inline code (or other items such as system commands), you must switch to HTML mode and surround your text with <code></code> tags. Using the Epoz editor, you can switch to HTML mode by checking the HTML box beneath the editor.For example, to get this output:
Look in
/usr/local/python/lib for the necessary files.You would use the following HTML:
Look in <code>/usr/local/python/lib</code> for the necessary files.