Help text style guide: Difference between revisions
Carandraug (talk | contribs) (→Special inserts: how to mention matlab) |
Carandraug (talk | contribs) (→Formatting: change subsections by what a user may want and not by existing evironments. Also explain how to add TeX mathematical formulas) |
||
Line 41: | Line 41: | ||
== Formatting == | == Formatting == | ||
=== | |||
=== Formulas === | |||
Do not use the example environment to insert formulas, consider using {{Codeline|@verbatim}} instead. | |||
{{Code||<pre> | |||
@verbatim | |||
E[Z(i,k) ] | |||
IRL(k) = ------------ | |||
V(i) | |||
@end verbatim | |||
</pre>}} | |||
However, this will never print as a nice looking mathematical formula that TeX is known for. It is possible to have Tex formulas but then they won't be displayed on HTML or Info (Octave help) so the following can be done: | |||
{{Code||<pre> | {{Code||<pre> | ||
@tex | |||
\def\frac#1#2{{\begingroup#1\endgroup\over#2}} | |||
$$ IRL(k) = \frac{E[Z(i,k)]}{V(i)} $$ | |||
@end tex | |||
@ifnottex | |||
@verbatim | @verbatim | ||
E[Z(i,k) ] | E[Z(i,k) ] | ||
Line 50: | Line 66: | ||
V(i) | V(i) | ||
@end verbatim | @end verbatim | ||
@end ifnottex | |||
</pre>}} | </pre>}} | ||
=== Plain-tex missing macros === | |||
When compared to LaTeX, plain TeX is missing some very useful macros for including mathematical notation. The following is a list of their definitions which can be added on a as needed basis: | |||
* frac | |||
<pre>\def\frac#1#2{{\begingroup#1\endgroup\over#2}}</pre> | |||
== Special inserts == | == Special inserts == |
Revision as of 14:54, 10 November 2014
Functions should have help text so that people know how to use it.
Guidelines
First sentence
The first sentence of help text should start with a statement that is like a command. For example, the first sentence of hist
:
Produce histogram counts or plots. # good Produces histogram counts or plots. # bad hist produces histogram counts or plots. # bad
Manual reference
When submitting a function to Octave, a tag for the docstring should be added to some appropriate place in one of the manual's .txi source files (they are all in doc/interpreter/). Find the most appropriate section in the manual and add the following with the related functions:
Code: adding tag for function help text in Octave's manual |
+@DOCSTRING(function_name) |
If appropriate, also write some text about the function on the manual for better inclusion into the manual.
Sentence spacing
The typographical convention in Octave is to use two full spaces after a period that ends a sentence. For example:
there is no correct for sentence spacing. But we need a convention # good there is no correct for sentence spacing. But we need a convention # bad
TexInfo
This is the preferred format for help text. There is also a comprehensive TexInfo manual.
Octave specific macros
seealso
Do not use this macro empty as it will create problems with the generate_html package.
deftypefn
This environment will enclose the function help text. It takes as argument the type of function. Typical values are
- Function File -- for functions in .m files
- Loadable Function -- for functions in .oct files
- Accessor method
- Class property
Besides this environment there is also the alternative deftypenx
for alternative forms. Typically these are mentioned at the top of the help text, right after the deftypen
although this is not really necessary. Cases where it's acceptable to have them on other sections would be methods on the help text of a class constructor, since they will not always be on a separate file.
Formatting
Formulas
Do not use the example environment to insert formulas, consider using @verbatim
instead.
@verbatim E[Z(i,k) ] IRL(k) = ------------ V(i) @end verbatim |
However, this will never print as a nice looking mathematical formula that TeX is known for. It is possible to have Tex formulas but then they won't be displayed on HTML or Info (Octave help) so the following can be done:
@tex \def\frac#1#2{{\begingroup#1\endgroup\over#2}} $$ IRL(k) = \frac{E[Z(i,k)]}{V(i)} $$ @end tex @ifnottex @verbatim E[Z(i,k) ] IRL(k) = ------------ V(i) @end verbatim @end ifnottex |
Plain-tex missing macros
When compared to LaTeX, plain TeX is missing some very useful macros for including mathematical notation. The following is a list of their definitions which can be added on a as needed basis:
- frac
\def\frac#1#2{{\begingroup#1\endgroup\over#2}}
Special inserts
Escape characters
To escape characters in TexInfo, use the character @
. Only the characters @, { and } need to be escaped.
@@
stands for a single @ (do not put braces after an@@
command)@{
stands for a single {@}
stands for a single }
In certain contexts (such as @acronym
or @xref
), commas may need to be escaped. In such situations, use @comma{}
.
Ellipsis (...)
Ellipsis are frequently used in octave help text, specially when defining a function API. Use the @dots{}
rather than three dots.
@deftypefn {Function File} {} imhist (@var{I}) @deftypefnx {Function File} {[@var{counts}, @var{x}] =} imhist (@dots{}) |
Matlab
Sometimes it is need to mention matlab in the help text. For example, to mention that a weird behavior needs to be kept for matlab compatibility. In such case, small caps should be used. For example, the following is used in the length
help text:
For matrix objects, the length is the number of rows or columns, whichever is greater (this odd definition is used for compatibility with @sc{matlab}). |