Unless supplying -types -methods, goreadme fails to include ExampleT_M-typed examples. The documentation is not clear about this behavior or the needed remedy.
The testing package mentions that there are several naming conventions for typical test types:
The naming convention to declare examples for the package, a function F, a type T and method M on type T are:
Multiple example functions for a package/type/function/method may be provided by appending a distinct suffix to the name. The suffix must start with a lower-case letter.
Examples of the form ExampleT_M() do not render in the generated readme by default. Our package has the type Client struct which has the methods Evaluate and BulkEvaluate. When I have my example func ExampleClient_Evaluate, that example is not added to the readme. When I change it to ExampleClient_evaluate, it is then rendered in the readme with the Evaluate header (Client is excluded).
When supplying the -types parameter alone, this behavior remains (though, when providing -types, ExampleClient_evaluate is then correctly placed under the Client header as expected).
While I tried to figure out where I was going wrong with my example names to make them not be included, I ran a local godoc server to see if godoc itself was failing to parse the examples. This confirmed to me that the examples were named correctly and goreadme was failing to find them:
ExampleClient_evaluate is marked as an Evaluate example on Client. Likewise, ExampleClient_bulkEvaluate is marked as a BulkEvaluate example on Client.
these are the examples which goreadme is able to parse
ExampleClient_Evaluate is marked as an example of Client.Evaluate, and ExampleClient_BulkEvaluate is marked as an example of Client.BulkEvaluate.
The ExampleT_M_suffix() cases are similarly ignored.
It would be nice if the documentation was a bit clearer about the need to specify -types -methods to force these examples to be included; additionally, it would also be nice to [have an option to] be able to just render all of the method examples without having to include all -types -methods in the readme, as doing so can bring with a fair amount of extra information which doesn't otherwise need to be in the readme.
Unless supplying
-types -methods
, goreadme fails to includeExampleT_M
-typed examples. The documentation is not clear about this behavior or the needed remedy.The testing package mentions that there are several naming conventions for typical test types:
Examples of the form
ExampleT_M()
do not render in the generated readme by default. Our package has thetype Client struct
which has the methodsEvaluate
andBulkEvaluate
. When I have my example funcExampleClient_Evaluate
, that example is not added to the readme. When I change it toExampleClient_evaluate
, it is then rendered in the readme with theEvaluate
header (Client
is excluded).When supplying the
-types
parameter alone, this behavior remains (though, when providing-types
,ExampleClient_evaluate
is then correctly placed under theClient
header as expected).While I tried to figure out where I was going wrong with my example names to make them not be included, I ran a local godoc server to see if godoc itself was failing to parse the examples. This confirmed to me that the examples were named correctly and goreadme was failing to find them:
ExampleClient_evaluate
is marked as anEvaluate
example onClient
. Likewise,ExampleClient_bulkEvaluate
is marked as aBulkEvaluate
example onClient
.ExampleClient_Evaluate
is marked as an example ofClient.Evaluate
, andExampleClient_BulkEvaluate
is marked as an example ofClient.BulkEvaluate
.The
ExampleT_M_suffix()
cases are similarly ignored.It would be nice if the documentation was a bit clearer about the need to specify
-types -methods
to force these examples to be included; additionally, it would also be nice to [have an option to] be able to just render all of the method examples without having to include all-types -methods
in the readme, as doing so can bring with a fair amount of extra information which doesn't otherwise need to be in the readme.