...
{snippet:id=sitegraph-usage|lang=none|url=webwork/src/java/com/opensymphony/webwork/sitegraph/sitegraph-usage.txt}
or
{snippet:id=ajax-validation-example|lang=xml|url=webwork/webapps/ajax/src/webapp/lesson1/example.jsp}
Where:
- id is the name of the snippet (*required).
- url is the URL where the snippet can be found (required).
- lang is the language that the code block should be required as. If this snippet is simply text, don't include this parameter and the content will be printed outside of a code block.
- javadoc indicates if the content is within a JavaDoc block. If this is set to true, then the preceeding "* " (asterisk-space) characters will be stripped before printing the content out. Also, the content is assumed to the HTML escaped already and therefore won't be escaped again.
...
- If the URL appears to be a class, we assume it lives in src/java, convert all the dots to slashes, and then append .java to it.
- If the URL doesn't start with "http", then it is assumed to start with _https://opensymphony.dev.java.net/source/browse/*checkout*/_
, as you saw in the third example.
Note that the short-hand class notation will only work for top-level projects (WebWork, OSWorkflow, etc) and not any sub-projects within the projects, such as example webapps in WebWork. If you wish to include content from a class in a sub-project, you'll need to list out the full path, like in the fourth example.
A note about snippet markers
All snippet markers should be commented out if possible. How they are commented out depends on where the snippet is. If the snippet is for HTML or XML, you can do:
Code Block | ||
---|---|---|
| ||
<!-- START SNIPPET: xxx --> ... <!-- END SNIPPET: xxx --> |
If the snippet is in Java code, you can do:
Code Block | ||
---|---|---|
| ||
if (true != false) {
// START SNIPPET: xxx
System.out.println("This is some silly code!");
// END SNIPPET: xxx
}
|
If the snippet is found in JavaDocs, you should use HTML comments as they won't render in the JavaDocs. For XML examples in JavaDocs (see Timer Interceptor for an example), it can be a bit tricky. This is because in your JavaDocs you want to use the <pre> tag, but you don't want the wiki to display it. A good technique is to embed the snippet markers inside the <pre> tag:
Code Block | ||
---|---|---|
| ||
* <pre>
* <!-- START SNIPPET: example -->
* <!-- records only the action's execution time -->
* <action name="someAction" class="com.examples.SomeAction">
* <interceptor-ref name="completeStack"/>
* <interceptor-ref name="timer"/>
* <result name="success">good_result.ftl</result>
* </action>
* <!-- END SNIPPET: example -->
|
About Headings
This section refers to: Notation Guide >> Headings.
...