Prev Next

Example Including Source Code

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.

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

Execute The Following Steps

src_example.omh
Use an editor of your choice to create the file src_example.omh in the test 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%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%src_example.py%5%# BEGIN USAGE%# END USAGE%$$
     
     $end
Note that you can copy and paste the commands above to your editor window. You may just copy the file with the same name from the getting started directory .

Example In This Web Site Context
You can view the result of making src_example.omh part of the OMhelp help web site by selecting src_example .

Execute OMhelp
In a command window and in the htm directory execute the following command
 
     omhelp ../src_example.omh -noframe

Example by Itself
Use a web browser of your choosing to view the file test/htm/src_example.htm .
Input File: getstarted/start_src.omh