Method Body

When you need to extract a specific method body use the include-groovy plugin.Consider the following file: class HelloWorldTest { @Test void "should calculate risk based on epsilon"() { generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 } @Test void "should calculate risk without quantity"() { generateStatement(price: 10, epsilon: 2) calcRisk().should == 108 } } Specify a method name to extract it from the file. :include-groovy: HelloWorldTest.groovy {entry: "should calculate risk based on epsilon", bodyOnly: true} If bodyOnly is specified, signature will be omitted. generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108

Multiple Bodies

Pass list as entry to extract multiple method bodies markdown :include-groovy: HelloWorldTest.groovy { title: "api example", entry: ["should calculate risk based on epsilon", "should calculate risk based on epsilon"], bodyOnly: true } generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 Pass entrySeparator: "<separator>" to have a provided line in between entries as a separator. markdown :include-groovy: HelloWorldTest.groovy { title: "api example", entry: ["should calculate risk based on epsilon", "should calculate risk based on epsilon"], entrySeparator: "", bodyOnly: true } generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108 generateStatement(price: 10, quantity: 10, epsilon: 2) calcRisk().should == 108

Overloads

Specify types inside brackets to select an overloaded versions of your methods.Types should appear as they do in the file, i.e., if you use the short version of a type, you need to use the short version inside the plugin. import your.company.com.util.* /* groovy docs on top */ class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } :include-groovy: HelloWorld.groovy {entry: "methodName(List, Map)"} :include-groovy: HelloWorld.groovy {entry: "methodName(def,def)"} Note: Generic types are erased and spaces after commas are optional void methodName(List<String> a, Map<String, Integer> b) { actionA() } Note: def type remains def and not Object void methodName(def a, def b) { actionC() }

Class Body

import your.company.com.util.* /* groovy docs on top */ class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } To extract class body use: :include-groovy: HelloWorld.groovy {entry: "HelloWorld"} class HelloWorld { void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() } } Use bodyOnly to only display only the body of your class. :include-groovy: HelloWorld.groovy {entry: "HelloWorld", bodyOnly: true} void methodName(List<String> a, Map<String, Integer> b) { actionA() } void methodName(List<String> a, Boolean b) { actionB() } void methodName(def a, def b) { actionC() }