Prev Next

Example Including Source Code

srcfile
srcthisfile
srccode
src_example.omh
src_example.py
Execute Example
Example In This Web Site

srcfile
The srcfile command enables one to include all of part of a source code file. This is useful for including examples in the documentation with source code highlighting.

srcthisfile
The srcthisfile command enables one to include all of part of the current input file. This can include part of the current input file, in the documentation, with source code highlighting.

srccode
The srccode command enables one to include line text with source code highlighting.

src_example.omh
Use the editor of your choice to create the file src_example.omh in the xam directory with the following contents:
 
     $begin src_example$$
     $spell
     	inline src srcfile py newline
     $$
     
     $section Example Inclusion of Source Code$$
     
     $head Inline Source Code$$
     The following is an example of in-line source code
     $srccode%cpp%
     	extern std::set< std::string > string_set(const char* c_string);
     %$$
     
     $head Contents of src_example.py$$
     Note that a newline is automatically added at the beginning
     of a file:
     $srcfile%omh/getstarted/src_example.py%5%$$
     
     $head Escape Character$$
     Change the escape character from $code #$$ to $code !$$
     so $code #$$ can be used normally as part of the start
     and stop sequences:
     $escape !$$
     
     $head Just Usage Message$$
     Note that the newline following
     $code # BEGIN USAGE$$ is included:
     $srcfile%omh/getstarted/src_example.py%
     	5%# BEGIN USAGE%# END USAGE%0
     %$$
     
     $childtable%omh/getstarted/src_example.py%$$
     
     $end
You can also just copy src_example.omh from the omh/getstarted directory .

src_example.py
Copy omh/getstarted/src_example.py from the omh/getstarted Directory to the xam directory . In the copy of src_example.omh, change omh/getstarted/src_example.py to src_example.py.

Execute Example
Once you have copied the files mentioned above, you can execute omhelp with example_name equal to src_example.

Example In This Web Site
You can view the result of making src_example.omh part of the OMhelp help web site by selecting src_example .
Input File: omh/getstarted/start_src.omh