diff --git a/test/samples-all.generated.js b/test/samples-all.generated.js index 21723e6b..678bd267 100644 --- a/test/samples-all.generated.js +++ b/test/samples-all.generated.js @@ -88,6 +88,10 @@ define([], function() { return[ "name": "sample.go.txt", "content": "// We often need our programs to perform operations on\r\n// collections of data, like selecting all items that\r\n// satisfy a given predicate or mapping all items to a new\r\n// collection with a custom function.\r\n\r\n// In some languages it's idiomatic to use [generic](http://en.wikipedia.org/wiki/Generic_programming)\r\n// data structures and algorithms. Go does not support\r\n// generics; in Go it's common to provide collection\r\n// functions if and when they are specifically needed for\r\n// your program and data types.\r\n\r\n// Here are some example collection functions for slices\r\n// of `strings`. You can use these examples to build your\r\n// own functions. Note that in some cases it may be\r\n// clearest to just inline the collection-manipulating\r\n// code directly, instead of creating and calling a\r\n// helper function.\r\n\r\npackage main\r\n\r\nimport \"strings\"\r\nimport \"fmt\"\r\n\r\n// Returns the first index of the target string `t`, or\r\n// -1 if no match is found.\r\nfunc Index(vs []string, t string) int {\r\n for i, v := range vs {\r\n if v == t {\r\n return i\r\n }\r\n }\r\n return -1\r\n}\r\n\r\n// Returns `true` if the target string t is in the\r\n// slice.\r\nfunc Include(vs []string, t string) bool {\r\n return Index(vs, t) >= 0\r\n}\r\n\r\n// Returns `true` if one of the strings in the slice\r\n// satisfies the predicate `f`.\r\nfunc Any(vs []string, f func(string) bool) bool {\r\n for _, v := range vs {\r\n if f(v) {\r\n return true\r\n }\r\n }\r\n return false\r\n}\r\n\r\n// Returns `true` if all of the strings in the slice\r\n// satisfy the predicate `f`.\r\nfunc All(vs []string, f func(string) bool) bool {\r\n for _, v := range vs {\r\n if !f(v) {\r\n return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// Returns a new slice containing all strings in the\r\n// slice that satisfy the predicate `f`.\r\nfunc Filter(vs []string, f func(string) bool) []string {\r\n vsf := make([]string, 0)\r\n for _, v := range vs {\r\n if f(v) {\r\n vsf = append(vsf, v)\r\n }\r\n }\r\n return vsf\r\n}\r\n\r\n// Returns a new slice containing the results of applying\r\n// the function `f` to each string in the original slice.\r\nfunc Map(vs []string, f func(string) string) []string {\r\n vsm := make([]string, len(vs))\r\n for i, v := range vs {\r\n vsm[i] = f(v)\r\n }\r\n return vsm\r\n}\r\n\r\nfunc main() {\r\n\r\n // Here we try out our various collection functions.\r\n var strs = []string{\"peach\", \"apple\", \"pear\", \"plum\"}\r\n\r\n fmt.Println(Index(strs, \"pear\"))\r\n\r\n fmt.Println(Include(strs, \"grape\"))\r\n\r\n fmt.Println(Any(strs, func(v string) bool {\r\n return strings.HasPrefix(v, \"p\")\r\n }))\r\n\r\n fmt.Println(All(strs, func(v string) bool {\r\n return strings.HasPrefix(v, \"p\")\r\n }))\r\n\r\n fmt.Println(Filter(strs, func(v string) bool {\r\n return strings.Contains(v, \"e\")\r\n }))\r\n\r\n // The above examples all used anonymous functions,\r\n // but you can also use named functions of the correct\r\n // type.\r\n fmt.Println(Map(strs, strings.ToUpper))\r\n\r\n}\r\n" }, + { + "name": "sample.graphql.txt", + "content": "# GraphQL Schema Definition Language\n\n\"\"\"\nColor value\n\"\"\"\nscalar Color\n\n\"\"\"\nNode interface\n\n- allows (re)fetch arbitrary entity only by ID\n- allows client side cache normalization\n\nSee [Relay Global Object Identification Specification](https://facebook.github.io/relay/graphql/objectidentification.htm)\n\"\"\"\ninterface Node {\n \"\"\"\n Globally unique identifier,\n typically `${__typename}:${dbId}`\n may be encoded in *base64*\n \"\"\"\n id: ID!\n}\n\n\"\"\"\nA character in the Star Wars Trilogy\n\"\"\"\ninterface Character {\n \"\"\"\n The id of the character.\n \"\"\"\n id: ID!\n\n \"\"\"\n The name of the character.\n \"\"\"\n name: String\n\n \"\"\"\n The friends of the character, or an empty list if they have none.\n \"\"\"\n friends: [Character]\n\n \"\"\"\n Which movies they appear in\n \"\"\"\n appearsIn: [Episode]\n\n \"\"\"\n All secrets about their past\n \"\"\"\n secretBackstory: String\n}\n\n\"\"\"\nA mechanical creature in the Star Wars universe.\n\"\"\"\ntype Droid implements Character {\n \"\"\"\n The id of the droid.\n \"\"\"\n id: ID!\n\n \"\"\"\n The name of the droid.\n \"\"\"\n name: String\n\n \"\"\"\n The friends of the droid, or an empty list if they have none.\n \"\"\"\n friends: [Character]\n\n \"\"\"\n Which movies they appear in.\n \"\"\"\n appearsIn: [Episode]\n\n \"\"\"\n Construction date and the name of the designer.\n \"\"\"\n secretBackstory: String\n\n \"\"\"\n The primary function of the droid.\n \"\"\"\n primaryFunction: String\n\n \"\"\"\n Chase color of the droid.\n \"\"\"\n color: Color\n}\n\n# One of the films in the Star Wars Trilogy\nenum Episode {\n \"\"\"\n Released in 1977.\n \"\"\"\n NEWHOPE\n\n \"\"\"\n Released in 1980.\n \"\"\"\n EMPIRE\n\n \"\"\"\n Released in 1983.\n \"\"\"\n JEDI\n}\n\n\"\"\"\nA humanoid creature in the Star Wars universe.\n\"\"\"\ntype Human implements Character {\n \"\"\"\n The id of the human.\n \"\"\"\n id: ID!\n\n \"\"\"\n The name of the human.\n \"\"\"\n name: String\n\n \"\"\"\n The friends of the human, or an empty list if they have none.\n \"\"\"\n friends: [Character]\n\n \"\"\"\n Which movies they appear in.\n \"\"\"\n appearsIn: [Episode]\n\n \"\"\"\n The home planet of the human, or null if unknown.\n \"\"\"\n homePlanet: String\n\n \"\"\"\n Where are they from and how they came to be who they are.\n \"\"\"\n secretBackstory: String\n}\n\nenum LengthUnit {\n METER\n FEET\n}\n\ntype Starship {\n id: ID!\n name: String!\n length(unit: LengthUnit = METER): Float\n}\n\nunion SearchResult = Human | Droid | Starship\n\ninput SearchInput {\n name: String\n episode: Episode\n}\n\n\"\"\"\nRoot Query\n\"\"\"\ntype Query {\n \"\"\"\n Return the hero by episode.\n \"\"\"\n hero(\n \"\"\"\n If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.\n \"\"\"\n episode: Episode\n ): Character\n\n \"\"\"\n Return the Human by ID.\n \"\"\"\n human(\n \"\"\"\n id of the human\n \"\"\"\n id: ID!\n ): Human\n\n \"\"\"\n Return the Droid by ID.\n \"\"\"\n droid(\n \"\"\"\n id of the droid\n \"\"\"\n id: ID!\n ): Droid\n\n \"\"\"\n Search everything by name\n\n __NOTE__: You should use Relay pagination\n \"\"\"\n search(search: SearchInput!): [SearchResult]\n @deprecated(reason: \"`search` will be replaced.\")\n}\n\n\"\"\"\nRoot Mutation\n\"\"\"\ntype Mutation {\n \"\"\"\n Save the favorite episode.\n \"\"\"\n favorite(\n \"\"\"\n Favorite episode.\n \"\"\"\n episode: Episode!\n ): Episode\n}\n\n\"\"\"\nSubscriptions — live events\n\"\"\"\ntype Subscription {\n \"\"\"\n Message\n \"\"\"\n message: String\n}\n\nextend type Query {\n \"\"\"\n Dummy query for highlighting test\n \"\"\"\n dummy(\n int: Int = 123\n float: Float = 123.456\n str: String = \"Hello World!\"\n boolDefaultTrue: Boolean = true\n boolDefaultFalse: Boolean = false\n id: ID\n search: SearchInput = null\n ): Boolean\n}\n\nschema {\n query: Query\n mutation: Mutation\n subscription: Subscription\n}\n\n# GraphQL Query Language\n\nquery dummyQuery($int: Int) {\n dummy(int: $int)\n}\n\nmutation favoriteEpisode($episode: Episode) {\n favorite(episode: $episode)\n}\n" + }, { "name": "sample.handlebars.txt", "content": "\n