HandWiki:Help/SourceCode

From HandWiki
Jump to: navigation, search
Table of contents

Showing code

To show programming code, use the "source" tag (and specify the language):

Java="OK";
File F = new File();

For showing source code examples from DataMelt project, use the "jcode" statement. The first word should be "dmelt", the second - id of the example.

from jhplot  import *
f1 = F1D("2*exp(-x*x/50)+sin(pi*x)/x", 1.0, 10.0)
c1 = HPlot("Example of  function")
c1.visible()
c1.setAutoRange()
c1.draw(f1)

which is programmed as:

<jcode lang="python">
dmelt 27777667.py
</jcode>

If the example is protected, you will see a yellow box instead. You can also type code inside "jcode", but this will be less efficient than using the "source" statement assuming the Java syntax.

You can also show code using the "pycode" tag (Python syntax). This is a more protected approach since it shows a yellow box if not a member:

You can also use this:

def quickSort(arr):
	less = []
	pivotList = []
	more = []
	if len(arr) <= 1:
		return arr
	else:
		pass

codded as:

<source lang="Python" line='line'>
def quickSort(arr):
	less = []
	pivotList = []
	more = []
	if len(arr) <= 1:
		return arr
	else:
		pass
</source>
console.log('Some JavaScript code');
console.log('Some Java code');
console.log('Some Python code');

If you do not need syntax highlighting, the best way to show outputs is to use "pre" tag.

Including Javadoc

Native Java classes can be identified automatically as "Java documentation" links. For example,

jhplot.H1D jhplot.H1D

is programmed as:

<javadoc>jhplot.H1D</javadoc>

Here is another example: java.lang.String java.lang.String which is programmed as:

<javadoc>java.lang.String</javadoc>