Return info for expanding a sample into a template. Args: api: string, name of api. keywords: list of string, list of keywords for the given api. dirname: string, directory name of the sample. desc: string, long description of the sample. uri: string, uri of the sample code if
(api, keywords, dirname, desc, uri)
| 94 | |
| 95 | |
| 96 | def context_from_sample(api, keywords, dirname, desc, uri): |
| 97 | """Return info for expanding a sample into a template. |
| 98 | |
| 99 | Args: |
| 100 | api: string, name of api. |
| 101 | keywords: list of string, list of keywords for the given api. |
| 102 | dirname: string, directory name of the sample. |
| 103 | desc: string, long description of the sample. |
| 104 | uri: string, uri of the sample code if provided in the README. |
| 105 | |
| 106 | Returns: |
| 107 | A dictionary of values useful for template expansion. |
| 108 | """ |
| 109 | if uri is None: |
| 110 | uri = BASE_HG_URI + dirname.replace("/", "%2F") |
| 111 | else: |
| 112 | uri = "".join(uri) |
| 113 | if api is None: |
| 114 | return None |
| 115 | else: |
| 116 | entry = DIRECTORY[api] |
| 117 | context = { |
| 118 | "api": api, |
| 119 | "version": entry["version"], |
| 120 | "api_name": wiki_escape(entry.get("title", entry.get("description"))), |
| 121 | "api_desc": wiki_escape(entry["description"]), |
| 122 | "api_icon": entry["icons"]["x32"], |
| 123 | "keywords": keywords, |
| 124 | "dir": dirname, |
| 125 | "uri": uri, |
| 126 | "desc": wiki_escape(desc), |
| 127 | } |
| 128 | return context |
| 129 | |
| 130 | |
| 131 | def keyword_context_from_sample(keywords, dirname, desc, uri): |
no test coverage detected
searching dependent graphs…