gobject-introspection 2.2.4-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +129 -0
  3. data/ext/gobject-introspection/depend +10 -0
  4. data/ext/gobject-introspection/extconf.rb +94 -0
  5. data/ext/gobject-introspection/gobject_introspection.def +5 -0
  6. data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
  7. data/ext/gobject-introspection/rb-gi-argument.c +2053 -0
  8. data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
  9. data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
  10. data/ext/gobject-introspection/rb-gi-callable-info.c +104 -0
  11. data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
  12. data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
  13. data/ext/gobject-introspection/rb-gi-constructor-info.c +133 -0
  14. data/ext/gobject-introspection/rb-gi-conversions.h +145 -0
  15. data/ext/gobject-introspection/rb-gi-enum-info.c +155 -0
  16. data/ext/gobject-introspection/rb-gi-field-info.c +153 -0
  17. data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
  18. data/ext/gobject-introspection/rb-gi-function-info.c +841 -0
  19. data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
  20. data/ext/gobject-introspection/rb-gi-loader.c +224 -0
  21. data/ext/gobject-introspection/rb-gi-method-info.c +83 -0
  22. data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
  23. data/ext/gobject-introspection/rb-gi-private.h +105 -0
  24. data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
  25. data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
  26. data/ext/gobject-introspection/rb-gi-repository.c +246 -0
  27. data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
  28. data/ext/gobject-introspection/rb-gi-struct-info.c +202 -0
  29. data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
  30. data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
  31. data/ext/gobject-introspection/rb-gi-types.h +71 -0
  32. data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
  33. data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
  34. data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
  35. data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
  36. data/ext/gobject-introspection/rb-gobject-introspection.c +44 -0
  37. data/ext/gobject-introspection/rb-gobject-introspection.h +60 -0
  38. data/extconf.rb +71 -0
  39. data/lib/2.0/gobject_introspection.so +0 -0
  40. data/lib/2.1/gobject_introspection.so +0 -0
  41. data/lib/2.2/gobject_introspection.so +0 -0
  42. data/lib/gobject-introspection.rb +53 -0
  43. data/lib/gobject-introspection/boxed-info.rb +28 -0
  44. data/lib/gobject-introspection/callable-info.rb +100 -0
  45. data/lib/gobject-introspection/collection-reader.rb +34 -0
  46. data/lib/gobject-introspection/interface-info.rb +32 -0
  47. data/lib/gobject-introspection/loader.rb +465 -0
  48. data/lib/gobject-introspection/object-info.rb +33 -0
  49. data/lib/gobject-introspection/repository.rb +32 -0
  50. data/lib/gobject-introspection/struct-info.rb +28 -0
  51. data/lib/gobject-introspection/union-info.rb +28 -0
  52. data/test/gobject-introspection-test-utils.rb +26 -0
  53. data/test/run-test.rb +45 -0
  54. data/test/test-arg-info.rb +68 -0
  55. data/test/test-base-info.rb +31 -0
  56. data/test/test-boxed-info.rb +21 -0
  57. data/test/test-callable-info.rb +49 -0
  58. data/test/test-callback-info.rb +29 -0
  59. data/test/test-constant-info.rb +24 -0
  60. data/test/test-enum-info.rb +61 -0
  61. data/test/test-field-type.rb +42 -0
  62. data/test/test-flags-info.rb +27 -0
  63. data/test/test-function-info.rb +39 -0
  64. data/test/test-interface-info.rb +97 -0
  65. data/test/test-loader.rb +30 -0
  66. data/test/test-object-info.rb +131 -0
  67. data/test/test-property-info.rb +38 -0
  68. data/test/test-registered-type-info.rb +35 -0
  69. data/test/test-repository.rb +62 -0
  70. data/test/test-signal-info.rb +40 -0
  71. data/test/test-struct-info.rb +57 -0
  72. data/test/test-type-info.rb +62 -0
  73. data/test/test-type-tag.rb +29 -0
  74. data/test/test-union-info.rb +21 -0
  75. data/test/test-value-info.rb +28 -0
  76. data/test/test-vfunc-info.rb +42 -0
  77. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  78. data/vendor/local/bin/g-ir-generate.exe +0 -0
  79. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  80. data/vendor/local/include/gobject-introspection-1.0/giarginfo.h +82 -0
  81. data/vendor/local/include/gobject-introspection-1.0/gibaseinfo.h +120 -0
  82. data/vendor/local/include/gobject-introspection-1.0/gicallableinfo.h +110 -0
  83. data/vendor/local/include/gobject-introspection-1.0/giconstantinfo.h +58 -0
  84. data/vendor/local/include/gobject-introspection-1.0/gienuminfo.h +82 -0
  85. data/vendor/local/include/gobject-introspection-1.0/gifieldinfo.h +71 -0
  86. data/vendor/local/include/gobject-introspection-1.0/gifunctioninfo.h +100 -0
  87. data/vendor/local/include/gobject-introspection-1.0/giinterfaceinfo.h +106 -0
  88. data/vendor/local/include/gobject-introspection-1.0/giobjectinfo.h +207 -0
  89. data/vendor/local/include/gobject-introspection-1.0/gipropertyinfo.h +56 -0
  90. data/vendor/local/include/gobject-introspection-1.0/giregisteredtypeinfo.h +64 -0
  91. data/vendor/local/include/gobject-introspection-1.0/girepository.h +239 -0
  92. data/vendor/local/include/gobject-introspection-1.0/girffi.h +104 -0
  93. data/vendor/local/include/gobject-introspection-1.0/gisignalinfo.h +57 -0
  94. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +77 -0
  95. data/vendor/local/include/gobject-introspection-1.0/gitypeinfo.h +87 -0
  96. data/vendor/local/include/gobject-introspection-1.0/gitypelib.h +80 -0
  97. data/vendor/local/include/gobject-introspection-1.0/gitypes.h +524 -0
  98. data/vendor/local/include/gobject-introspection-1.0/giunioninfo.h +84 -0
  99. data/vendor/local/include/gobject-introspection-1.0/giversionmacros.h +128 -0
  100. data/vendor/local/include/gobject-introspection-1.0/givfuncinfo.h +73 -0
  101. data/vendor/local/lib/girepository-1.0/DBus-1.0.typelib +0 -0
  102. data/vendor/local/lib/girepository-1.0/DBusGLib-1.0.typelib +0 -0
  103. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  104. data/vendor/local/lib/girepository-1.0/GL-1.0.typelib +0 -0
  105. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  106. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  107. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  108. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  109. data/vendor/local/lib/girepository-1.0/cairo-1.0.typelib +0 -0
  110. data/vendor/local/lib/girepository-1.0/fontconfig-2.0.typelib +0 -0
  111. data/vendor/local/lib/girepository-1.0/freetype2-2.0.typelib +0 -0
  112. data/vendor/local/lib/girepository-1.0/libxml2-2.0.typelib +0 -0
  113. data/vendor/local/lib/girepository-1.0/win32-1.0.typelib +0 -0
  114. data/vendor/local/lib/girepository-1.0/xfixes-4.0.typelib +0 -0
  115. data/vendor/local/lib/girepository-1.0/xft-2.0.typelib +0 -0
  116. data/vendor/local/lib/girepository-1.0/xlib-2.0.typelib +0 -0
  117. data/vendor/local/lib/girepository-1.0/xrandr-1.3.typelib +0 -0
  118. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +24 -0
  119. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  120. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  121. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +76 -0
  122. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  123. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  124. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +2161 -0
  125. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  126. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  127. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +1139 -0
  128. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  129. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  130. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +203 -0
  131. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  132. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  133. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +202 -0
  134. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  135. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  136. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +173 -0
  137. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  138. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  139. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +23 -0
  140. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  141. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  142. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.py +305 -0
  143. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  144. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  145. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +120 -0
  146. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  147. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  148. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +72 -0
  149. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  150. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  151. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/callback.tmpl +4 -0
  152. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/class.tmpl +2 -0
  153. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/constructor.tmpl +1 -0
  154. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/default.tmpl +1 -0
  155. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/enum.tmpl +2 -0
  156. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/field.tmpl +1 -0
  157. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/function.tmpl +60 -0
  158. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/interface.tmpl +2 -0
  159. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/method.tmpl +1 -0
  160. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/namespace.tmpl +1 -0
  161. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/property.tmpl +5 -0
  162. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/record.tmpl +1 -0
  163. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/signal.tmpl +5 -0
  164. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/C/vfunc.tmpl +4 -0
  165. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/callback.tmpl +27 -0
  166. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/class.tmpl +30 -0
  167. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/constructor.tmpl +1 -0
  168. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/default.tmpl +1 -0
  169. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/enum.tmpl +21 -0
  170. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/field.tmpl +9 -0
  171. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/function.tmpl +47 -0
  172. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/interface.tmpl +17 -0
  173. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/method.tmpl +1 -0
  174. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/namespace.tmpl +2 -0
  175. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/property.tmpl +9 -0
  176. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/record.tmpl +2 -0
  177. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/signal.tmpl +38 -0
  178. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Gjs/vfunc.tmpl +27 -0
  179. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/callback.tmpl +27 -0
  180. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/class.tmpl +18 -0
  181. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/constructor.tmpl +1 -0
  182. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/default.tmpl +1 -0
  183. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/enum.tmpl +13 -0
  184. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/field.tmpl +1 -0
  185. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/function.tmpl +47 -0
  186. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/interface.tmpl +16 -0
  187. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/method.tmpl +1 -0
  188. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/namespace.tmpl +2 -0
  189. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/property.tmpl +9 -0
  190. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/record.tmpl +2 -0
  191. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/signal.tmpl +41 -0
  192. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/Python/vfunc.tmpl +27 -0
  193. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/base.tmpl +20 -0
  194. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/class.tmpl +61 -0
  195. data/vendor/local/lib/gobject-introspection/giscanner/doctemplates/namespace.tmpl +16 -0
  196. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +958 -0
  197. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  198. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  199. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +338 -0
  200. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  201. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  202. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +529 -0
  203. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  204. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  205. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +593 -0
  206. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  207. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  208. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +612 -0
  209. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  210. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  211. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +240 -0
  212. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  213. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  214. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +76 -0
  215. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  216. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  217. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +1366 -0
  218. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  219. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  220. data/vendor/local/lib/gobject-introspection/giscanner/message.py +203 -0
  221. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  222. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  223. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +561 -0
  224. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  225. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  226. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +152 -0
  227. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  228. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  229. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +140 -0
  230. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  231. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  232. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +329 -0
  233. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  234. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  235. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +136 -0
  236. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  237. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  238. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +971 -0
  239. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  240. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  241. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +211 -0
  242. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  243. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  244. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +156 -0
  245. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  246. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  247. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  248. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  249. data/vendor/local/lib/libgirepository-1.0.la +41 -0
  250. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +26 -0
  251. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +23 -0
  252. data/vendor/local/lib/pkgconfig/patched +0 -0
  253. data/vendor/local/share/aclocal/introspection.m4 +96 -0
  254. data/vendor/local/share/gir-1.0/DBus-1.0.gir +32 -0
  255. data/vendor/local/share/gir-1.0/DBusGLib-1.0.gir +18 -0
  256. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +4042 -0
  257. data/vendor/local/share/gir-1.0/GL-1.0.gir +31 -0
  258. data/vendor/local/share/gir-1.0/GLib-2.0.gir +47221 -0
  259. data/vendor/local/share/gir-1.0/GModule-2.0.gir +301 -0
  260. data/vendor/local/share/gir-1.0/GObject-2.0.gir +14733 -0
  261. data/vendor/local/share/gir-1.0/Gio-2.0.gir +82459 -0
  262. data/vendor/local/share/gir-1.0/cairo-1.0.gir +70 -0
  263. data/vendor/local/share/gir-1.0/fontconfig-2.0.gir +18 -0
  264. data/vendor/local/share/gir-1.0/freetype2-2.0.gir +22 -0
  265. data/vendor/local/share/gir-1.0/libxml2-2.0.gir +25 -0
  266. data/vendor/local/share/gir-1.0/win32-1.0.gir +19 -0
  267. data/vendor/local/share/gir-1.0/xfixes-4.0.gir +10 -0
  268. data/vendor/local/share/gir-1.0/xft-2.0.gir +23 -0
  269. data/vendor/local/share/gir-1.0/xlib-2.0.gir +67 -0
  270. data/vendor/local/share/gir-1.0/xrandr-1.3.gir +16 -0
  271. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +166 -0
  272. data/vendor/local/share/gobject-introspection-1.0/gdump.c +569 -0
  273. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.c +831 -0
  274. data/vendor/local/share/gobject-introspection-1.0/tests/annotation.h +301 -0
  275. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.c +57 -0
  276. data/vendor/local/share/gobject-introspection-1.0/tests/drawable.h +44 -0
  277. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +1579 -0
  278. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +535 -0
  279. data/vendor/local/share/gobject-introspection-1.0/tests/foo.c +790 -0
  280. data/vendor/local/share/gobject-introspection-1.0/tests/foo.h +582 -0
  281. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +5426 -0
  282. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.h +1948 -0
  283. data/vendor/local/share/gobject-introspection-1.0/tests/gitestmacros.h +10 -0
  284. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +4068 -0
  285. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +1415 -0
  286. data/vendor/local/share/gobject-introspection-1.0/tests/utility.c +47 -0
  287. data/vendor/local/share/gobject-introspection-1.0/tests/utility.h +102 -0
  288. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.c +47 -0
  289. data/vendor/local/share/gobject-introspection-1.0/tests/warnlib.h +46 -0
  290. data/vendor/local/share/license/gobject-introspection/AUTHORS +9 -0
  291. data/vendor/local/share/license/gobject-introspection/COPYING +12 -0
  292. data/vendor/local/share/man/man1/g-ir-compiler.1 +42 -0
  293. data/vendor/local/share/man/man1/g-ir-generate.1 +29 -0
  294. metadata +363 -0
@@ -0,0 +1,27 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="synopsis">
3
+ <synopsis><code mime="text/x-python">
4
+ % if formatter.get_in_parameters(node):
5
+ @accepts(${', '.join((formatter.format_type(arg.type) for arg in formatter.get_in_parameters(node)))})
6
+ % endif
7
+ @returns(${formatter.format_type(node.retval.type) | x})
8
+ def on_${node.name}(${', '.join((arg.argname for arg in formatter.get_in_parameters(node)))}):
9
+ </code></synopsis></%block>
10
+ <%block name="details">
11
+ % if formatter.get_in_parameters(node) or node.retval:
12
+ <terms>
13
+ % for arg in formatter.get_in_parameters(node):
14
+ <item>
15
+ <title><code>${arg.argname}</code></title>
16
+ ${formatter.format(node, arg.doc)}
17
+ </item>
18
+ % endfor
19
+ % if node.retval and node.retval.type.ctype != 'void':
20
+ <item>
21
+ <title><code>Returns</code></title>
22
+ ${formatter.format(node, node.retval.doc)}
23
+ </item>
24
+ % endif
25
+ </terms>
26
+ % endif
27
+ </%block>
@@ -0,0 +1,18 @@
1
+ <%inherit file="/class.tmpl"/>
2
+ <%block name="synopsis">
3
+ <synopsis><code>
4
+ from gi.repository import ${namespace.name}
5
+
6
+ ${formatter.to_underscores(node).lower()} = ${namespace.name}.${node.name}(\
7
+ % if isinstance(node, (ast.Class, ast.Interface)):
8
+ % for ix, property_ in enumerate(node.properties):
9
+ % if property_.construct or property_.construct_only or property_.writable:
10
+ <link xref='${namespace.name}.${node.name}-${property_.name}'>${property_.name.replace('-', '_')}</link>=value\
11
+ % if ix != len(node.properties) - 1:
12
+ , \
13
+ % endif
14
+ % endif
15
+ % endfor
16
+ % endif
17
+ )
18
+ </code></synopsis></%block>
@@ -0,0 +1 @@
1
+ <%inherit file="./function.tmpl"/>
@@ -0,0 +1 @@
1
+ <%inherit file="/base.tmpl"/>
@@ -0,0 +1,13 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="details">
3
+ % if node.members:
4
+ <terms>
5
+ % for member in node.members:
6
+ <item>
7
+ <title><code>${node.name}.${member.name.upper()}</code></title>
8
+ ${formatter.format(node, member.doc)}
9
+ </item>
10
+ % endfor
11
+ </terms>
12
+ % endif
13
+ </%block>
@@ -0,0 +1 @@
1
+ <%inherit file="/base.tmpl"/>
@@ -0,0 +1,47 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="info">
3
+ ${formatter.format_xref(node.parent, type="guide", group=page_kind)}
4
+ <api:function>
5
+ <api:returns>
6
+ <api:type>${formatter.format_type(node.retval.type) | x}</api:type>
7
+ </api:returns>
8
+ <api:name>${node.symbol}</api:name>
9
+ % for arg in formatter.get_in_parameters(node):
10
+ % if arg.type.ctype == '<varargs>':
11
+ <api:varargs/>
12
+ % else:
13
+ <api:arg>
14
+ <api:type>${formatter.format_type(arg.type) | x}</api:type>
15
+ <api:name>${formatter.format_parameter_name(node, arg)}</api:name>
16
+ </api:arg>
17
+ % endif
18
+ % endfor
19
+ </api:function>
20
+ </%block>
21
+ <%block name="synopsis">
22
+ <synopsis><code mime="text/x-python">
23
+ % if formatter.get_in_parameters(node):
24
+ @accepts(${', '.join((formatter.format_type(arg.type) for arg in formatter.get_in_parameters(node)))})
25
+ % endif
26
+ @returns(${formatter.format_type(node.retval.type) | x})
27
+ def ${node.name}(${', '.join((formatter.format_parameter_name(node, arg) for arg in formatter.get_in_parameters(node)))}):
28
+ # Python wrapper for ${node.symbol}()
29
+ </code></synopsis></%block>
30
+ <%block name="details">
31
+ % if formatter.get_in_parameters(node) or node.retval:
32
+ <terms>
33
+ % for ix, arg in enumerate(formatter.get_in_parameters(node)):
34
+ <item>
35
+ <title><code>${formatter.format_parameter_name(node, arg)}</code></title>
36
+ ${formatter.format(node, arg.doc)}
37
+ </item>
38
+ % endfor
39
+ % if node.retval and node.retval.type.ctype != 'void':
40
+ <item>
41
+ <title><code>Returns</code></title>
42
+ {formatter.format(node, node.retval.doc)}
43
+ </item>
44
+ % endif
45
+ </terms>
46
+ % endif
47
+ </%block>
@@ -0,0 +1,16 @@
1
+ <%inherit file="/class.tmpl"/>
2
+ <%block name="synopsis">
3
+ <synopsis><code>
4
+ from gi.repository import ${namespace.name}
5
+
6
+ ${formatter.to_underscores(node).lower()} = ${namespace.name}.${node.name}(\
7
+ % for ix, property_ in enumerate(node.properties):
8
+ % if property_.construct or property_.construct_only or property_.writable:
9
+ <link xref='${namespace.name}.${node.name}-${property_.name}'>${property_.name.replace('-', '_')}</link>=value\
10
+ % if ix != len(node.properties) - 1:
11
+ , \
12
+ % endif
13
+ % endif
14
+ % endfor
15
+ )\
16
+ </code></synopsis></%block>
@@ -0,0 +1 @@
1
+ <%inherit file="./function.tmpl"/>
@@ -0,0 +1,2 @@
1
+ <%! page_type="guide" %>\
2
+ <%inherit file="/namespace.tmpl"/>
@@ -0,0 +1,9 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="info">
3
+ ${formatter.format_xref(node.parent, type="guide", group=page_kind)}
4
+ <title type="link" role="topic">${node.name}</title>
5
+ </%block>
6
+ <%block name="synopsis">
7
+ <synopsis><code mime="text/x-python">
8
+ "${node.name}" ${formatter.format_type(node.type)} : ${formatter.format_property_flags(node)}
9
+ </code></synopsis></%block>
@@ -0,0 +1,2 @@
1
+ <%! page_type="guide" %>\
2
+ <%inherit file="/base.tmpl"/>
@@ -0,0 +1,41 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="info">
3
+ ${formatter.format_xref(node.parent, type="guide", group=page_kind)}
4
+ <title type="link" role="topic">${node.name}</title>
5
+ </%block>
6
+ <%block name="synopsis">
7
+ <synopsis><code mime="text/x-python">
8
+ def callback(${formatter.to_underscores(node.parent).lower()}, \
9
+ % for arg in formatter.get_in_parameters(node):
10
+ ${arg.argname}, \
11
+ % endfor
12
+ user_param1, ...)
13
+ </code></synopsis></%block>
14
+ <%block name="details">
15
+ <terms>
16
+ <item>
17
+ <title><code>${formatter.to_underscores(node.parent).lower()}</code></title>
18
+ <p>instance of ${formatter.format_xref(node.parent)} that is emitting the signal</p>
19
+ </item>
20
+ % for arg in formatter.get_in_parameters(node):
21
+ <item>
22
+ <title><code>${arg.argname}</code></title>
23
+ ${formatter.format(node, arg.doc)}
24
+ </item>
25
+ % endfor
26
+ <title><code>user_param1</code></title>
27
+ <p>first user parameter (if any) specified with the connect() method</p>
28
+ <item>
29
+ <title><code>...</code></title>
30
+ <p>additional user parameters (if any)</p>
31
+ </item>
32
+ % if node.retval and \
33
+ node.retval.type.ctype != 'void' and \
34
+ node.retval.type.ctype is not None:
35
+ <item>
36
+ <title><code>Returns</code></title>
37
+ ${formatter.format(node, node.retval.doc)}
38
+ </item>
39
+ % endif
40
+ </terms>
41
+ </%block>
@@ -0,0 +1,27 @@
1
+ <%inherit file="/base.tmpl"/>
2
+ <%block name="synopsis">
3
+ <synopsis><code mime="text/x-python">
4
+ % if formatter.get_in_parameters(node):
5
+ @accepts(${', '.join((formatter.format_type(arg.type) for arg in formatter.get_in_parameters(node)))})
6
+ % endif
7
+ @returns(${formatter.format_type(node.retval.type) | x})
8
+ def do_${node.name}(${', '.join((arg.argname for arg in formatter.get_in_parameters(node)))}):
9
+ </code></synopsis></%block>
10
+ <%block name="details">
11
+ % if formatter.get_in_parameters(node) or node.retval:
12
+ <terms>
13
+ % for arg in formatter.get_in_parameters(node):
14
+ <item>
15
+ <title><code>${arg.argname}</code></title>
16
+ ${formatter.format(node, arg.doc)}
17
+ </item>
18
+ % endfor
19
+ % if node.retval and node.retval.type.ctype != 'void':
20
+ <item>
21
+ <title><code>Returns</code></title>
22
+ ${formatter.format(node, node.retval.doc)}
23
+ </item>
24
+ % endif
25
+ </terms>
26
+ % endif
27
+ </%block>
@@ -0,0 +1,20 @@
1
+ <%! page_type="topic" %>\
2
+ <?xml version="1.0"?>
3
+ <page id="${page_id}"
4
+ type="${self.attr.page_type}"
5
+ style="${page_kind}"
6
+ xmlns="http://projectmallard.org/1.0/"
7
+ xmlns:api="http://projectmallard.org/experimental/api/"
8
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
9
+ <info><%block name="info">
10
+ ${formatter.format_xref(node.parent, type="guide", group=page_kind)}
11
+ </%block>\
12
+ </info>
13
+ <title><%block name="title">${formatter.format_page_name(node)}</%block></title><%block name="synopsis"></%block><%block name="doc">
14
+ ${formatter.format(node, node.doc)}
15
+ </%block><%block name="since_version">\
16
+ % if node.version:
17
+ <p>Since ${node.version}</p>\
18
+ % endif
19
+ </%block><%block name="details"></%block><%block name="links"></%block>
20
+ </page>
@@ -0,0 +1,61 @@
1
+ <%! page_type="guide" %>\
2
+ <%inherit file="/base.tmpl"/>
3
+ <%block name="details">
4
+ % if isinstance(node, ast.Class):
5
+ <synopsis>
6
+ <title>Hierarchy</title>
7
+ <tree>
8
+ % for class_ in formatter.get_class_hierarchy(node):
9
+ <item>
10
+ <code>${class_.namespace.name}.${class_.name}</code>
11
+ % endfor
12
+ % for class_ in formatter.get_class_hierarchy(node):
13
+ </item>
14
+ % endfor
15
+ </tree>
16
+ </synopsis>
17
+ % elif isinstance(node, ast.Interface):
18
+ <synopsis>
19
+ <title>Prerequisites</title>
20
+ <p>${node.name} requires ${formatter.format_prerequisites(node)}</p>
21
+ </synopsis>
22
+ <synopsis>
23
+ <title>Known Implementations</title>
24
+ <p>${formatter.format_known_implementations(node)}</p>
25
+ </synopsis>
26
+ % endif
27
+ </%block>
28
+ <%block name="links">\
29
+ <links type="topic" ui:expanded="true"
30
+ api:type="function" api:mime="${formatter.mime_type}"
31
+ groups="constructor" style="linklist">
32
+ <title>Constructors</title>
33
+ </links>
34
+ <links type="topic" ui:expanded="true"
35
+ api:type="function" api:mime="${formatter.mime_type}"
36
+ groups="method" style="linklist">
37
+ <title>Methods</title>
38
+ </links>
39
+ <links type="topic" ui:expanded="true"
40
+ api:type="function" api:mime="${formatter.mime_type}"
41
+ groups="function" style="linklist">
42
+ <title>Static Functions</title>
43
+ </links>
44
+ % if isinstance(node, (ast.Class, ast.Interface)):
45
+ <links type="topic" ui:expanded="true" groups="property" style="linklist">
46
+ <title>Properties</title>
47
+ </links>
48
+ <links type="topic" ui:expanded="true" groups="signal" style="linklist">
49
+ <title>Signals</title>
50
+ </links>
51
+ <links type="topic" ui:expanded="true" groups="vfunc" style="linklist">
52
+ <title>Virtual functions</title>
53
+ </links>
54
+ % endif
55
+ <links type="topic" ui:expanded="true" groups="field" style="linklist">
56
+ <title>Fields</title>
57
+ </links>
58
+ <links type="topic" ui:expanded="true" groups="#first #default #last" style="linklist">
59
+ <title>Other</title>
60
+ </links>\
61
+ </%block>
@@ -0,0 +1,16 @@
1
+ <%! page_type="guide" %>\
2
+ <%inherit file="/base.tmpl"/>
3
+ <%block name="doc"></%block>
4
+ <%block name="info"></%block>
5
+ <%block name="links">
6
+ <links type="topic" ui:expanded="true" groups="class interface" style="linklist">
7
+ <title>Classes</title>
8
+ </links>
9
+ <links type="topic" ui:expanded="true" groups="function" style="linklist">
10
+ <title>Functions</title>
11
+ </links>
12
+ <links type="topic" ui:expanded="true" groups="#first #default #last" style="linklist">
13
+ <title>Other</title>
14
+ </links>
15
+ </%block>
16
+ <%block name="since_version"></%block>
@@ -0,0 +1,958 @@
1
+ #!/usr/bin/env python
2
+ # -*- Mode: Python -*-
3
+ # GObject-Introspection - a framework for introspecting GObject libraries
4
+ # Copyright (C) 2010 Zach Goldberg
5
+ # Copyright (C) 2011 Johan Dahlin
6
+ # Copyright (C) 2011 Shaun McCance
7
+ #
8
+ # This program is free software; you can redistribute it and/or
9
+ # modify it under the terms of the GNU General Public License
10
+ # as published by the Free Software Foundation; either version 2
11
+ # of the License, or (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
+ # 02110-1301, USA.
22
+ #
23
+
24
+ import os
25
+ import re
26
+ import tempfile
27
+
28
+ from xml.sax import saxutils
29
+ from mako.lookup import TemplateLookup
30
+
31
+ from . import ast, xmlwriter
32
+ from .utils import to_underscores
33
+
34
+
35
+ def make_page_id(node, recursive=False):
36
+ if isinstance(node, ast.Namespace):
37
+ if recursive:
38
+ return node.name
39
+ else:
40
+ return 'index'
41
+
42
+ if hasattr(node, '_chain') and node._chain:
43
+ parent = node._chain[-1]
44
+ else:
45
+ parent = getattr(node, 'parent', None)
46
+
47
+ if parent is None:
48
+ if isinstance(node, ast.Function) and node.shadows:
49
+ return '%s.%s' % (node.namespace.name, node.shadows)
50
+ else:
51
+ return '%s.%s' % (node.namespace.name, node.name)
52
+
53
+ if isinstance(node, (ast.Property, ast.Signal, ast.VFunction, ast.Field)):
54
+ return '%s-%s' % (make_page_id(parent, recursive=True), node.name)
55
+ elif isinstance(node, ast.Function) and node.shadows:
56
+ return '%s.%s' % (make_page_id(parent, recursive=True), node.shadows)
57
+ else:
58
+ return '%s.%s' % (make_page_id(parent, recursive=True), node.name)
59
+
60
+
61
+ def get_node_kind(node):
62
+ if isinstance(node, ast.Namespace):
63
+ node_kind = 'namespace'
64
+ elif isinstance(node, (ast.Class, ast.Boxed, ast.Compound)):
65
+ node_kind = 'class'
66
+ elif isinstance(node, ast.Interface):
67
+ node_kind = 'interface'
68
+ elif isinstance(node, ast.Record):
69
+ node_kind = 'record'
70
+ elif isinstance(node, ast.Function):
71
+ if node.is_method:
72
+ node_kind = 'method'
73
+ elif node.is_constructor:
74
+ node_kind = 'constructor'
75
+ else:
76
+ node_kind = 'function'
77
+ elif isinstance(node, (ast.Enum, ast.Bitfield)):
78
+ node_kind = 'enum'
79
+ elif isinstance(node, ast.Property) and node.parent is not None:
80
+ node_kind = 'property'
81
+ elif isinstance(node, ast.Signal) and node.parent is not None:
82
+ node_kind = 'signal'
83
+ elif isinstance(node, ast.VFunction) and node.parent is not None:
84
+ node_kind = 'vfunc'
85
+ elif isinstance(node, ast.Callable):
86
+ node_kind = 'callback'
87
+ elif isinstance(node, ast.Field):
88
+ node_kind = 'field'
89
+ else:
90
+ node_kind = 'default'
91
+
92
+ return node_kind
93
+
94
+
95
+ class TemplatedScanner(object):
96
+ def __init__(self, specs):
97
+ self.specs = self.unmangle_specs(specs)
98
+ self.regex = self.make_regex(self.specs)
99
+
100
+ def unmangle_specs(self, specs):
101
+ mangled = re.compile('<<([a-zA-Z_:]+)>>')
102
+ specdict = dict((name.lstrip('!'), spec) for name, spec in specs)
103
+
104
+ def unmangle(spec, name=None):
105
+ def replace_func(match):
106
+ child_spec_name = match.group(1)
107
+
108
+ if ':' in child_spec_name:
109
+ pattern_name, child_spec_name = child_spec_name.split(':', 1)
110
+ else:
111
+ pattern_name = None
112
+
113
+ child_spec = specdict[child_spec_name]
114
+ # Force all child specs of this one to be unnamed
115
+ unmangled = unmangle(child_spec, None)
116
+ if pattern_name and name:
117
+ return '(?P<%s_%s>%s)' % (name, pattern_name, unmangled)
118
+ else:
119
+ return unmangled
120
+
121
+ return mangled.sub(replace_func, spec)
122
+
123
+ return [(name, unmangle(spec, name)) for name, spec in specs]
124
+
125
+ def make_regex(self, specs):
126
+ regex = '|'.join('(?P<%s>%s)' % (name, spec) for name, spec in specs
127
+ if not name.startswith('!'))
128
+ return re.compile(regex)
129
+
130
+ def get_properties(self, name, match):
131
+ groupdict = match.groupdict()
132
+ properties = {name: groupdict.pop(name)}
133
+ name = name + "_"
134
+ for group, value in groupdict.iteritems():
135
+ if group.startswith(name):
136
+ key = group[len(name):]
137
+ properties[key] = value
138
+ return properties
139
+
140
+ def scan(self, text):
141
+ pos = 0
142
+ while True:
143
+ match = self.regex.search(text, pos)
144
+ if match is None:
145
+ break
146
+
147
+ start = match.start()
148
+ if start > pos:
149
+ yield ('other', text[pos:start], None)
150
+
151
+ pos = match.end()
152
+ name = match.lastgroup
153
+ yield (name, match.group(0), self.get_properties(name, match))
154
+
155
+ if pos < len(text):
156
+ yield ('other', text[pos:], None)
157
+
158
+
159
+ class DocstringScanner(TemplatedScanner):
160
+ def __init__(self):
161
+ specs = [
162
+ ('!alpha', r'[a-zA-Z0-9_]+'),
163
+ ('!alpha_dash', r'[a-zA-Z0-9_-]+'),
164
+ ('property', r'#<<type_name:alpha>>:(<<property_name:alpha_dash>>)'),
165
+ ('signal', r'#<<type_name:alpha>>::(<<signal_name:alpha_dash>>)'),
166
+ ('type_name', r'#(<<type_name:alpha>>)'),
167
+ ('enum_value', r'%(<<member_name:alpha>>)'),
168
+ ('parameter', r'@<<param_name:alpha>>'),
169
+ ('function_call', r'<<symbol_name:alpha>>\(\)'),
170
+ ]
171
+
172
+ super(DocstringScanner, self).__init__(specs)
173
+
174
+
175
+ class DocFormatter(object):
176
+ def __init__(self, transformer):
177
+ self._transformer = transformer
178
+ self._scanner = DocstringScanner()
179
+
180
+ def escape(self, text):
181
+ return saxutils.escape(text)
182
+
183
+ def should_render_node(self, node):
184
+ if getattr(node, "private", False):
185
+ return False
186
+ # Nodes without namespace are AST bugs really
187
+ # They are used for structs and unions declared
188
+ # inline inside other structs, but they are not
189
+ # even picked up by g-ir-compiler, because they
190
+ # don't create a <type/> element.
191
+ # So just ignore them.
192
+ if isinstance(node, ast.Node) and node.namespace is None:
193
+ return False
194
+
195
+ return True
196
+
197
+ def format(self, node, doc):
198
+ if doc is None:
199
+ return ''
200
+
201
+ result = ''
202
+ for para in doc.split('\n\n'):
203
+ result += ' <p>'
204
+ result += self.format_inline(node, para)
205
+ result += '</p>'
206
+ return result
207
+
208
+ def _resolve_type(self, ident):
209
+ try:
210
+ matches = self._transformer.split_ctype_namespaces(ident)
211
+ except ValueError:
212
+ return None
213
+ for namespace, name in matches:
214
+ node = namespace.get(name)
215
+ if node:
216
+ return node
217
+ return None
218
+
219
+ def _resolve_symbol(self, symbol):
220
+ try:
221
+ matches = self._transformer.split_csymbol_namespaces(symbol)
222
+ except ValueError:
223
+ return None
224
+ for namespace, name in matches:
225
+ node = namespace.get_by_symbol(symbol)
226
+ if node:
227
+ return node
228
+ return None
229
+
230
+ def _find_thing(self, list_, name):
231
+ for item in list_:
232
+ if item.name == name:
233
+ return item
234
+ raise KeyError("Could not find %s" % (name, ))
235
+
236
+ def _process_other(self, node, match, props):
237
+ return self.escape(match)
238
+
239
+ def _process_property(self, node, match, props):
240
+ type_node = self._resolve_type(props['type_name'])
241
+ if type_node is None:
242
+ return match
243
+
244
+ try:
245
+ prop = self._find_thing(type_node.properties, props['property_name'])
246
+ except (AttributeError, KeyError):
247
+ return match
248
+
249
+ return self.format_xref(prop)
250
+
251
+ def _process_signal(self, node, match, props):
252
+ type_node = self._resolve_type(props['type_name'])
253
+ if type_node is None:
254
+ return match
255
+
256
+ try:
257
+ signal = self._find_thing(type_node.signals, props['signal_name'])
258
+ except (AttributeError, KeyError):
259
+ return match
260
+
261
+ return self.format_xref(signal)
262
+
263
+ def _process_type_name(self, node, match, props):
264
+ type_ = self._resolve_type(props['type_name'])
265
+ if type_ is None:
266
+ return match
267
+
268
+ return self.format_xref(type_)
269
+
270
+ def _process_enum_value(self, node, match, props):
271
+ member_name = props['member_name']
272
+
273
+ try:
274
+ return '<code>%s</code>' % (self.fundamentals[member_name], )
275
+ except KeyError:
276
+ pass
277
+
278
+ enum_value = self._resolve_symbol(member_name)
279
+ if enum_value:
280
+ return self.format_xref(enum_value)
281
+
282
+ return match
283
+
284
+ def _process_parameter(self, node, match, props):
285
+ try:
286
+ parameter = node.get_parameter(props['param_name'])
287
+ except (AttributeError, ValueError):
288
+ return match
289
+
290
+ return '<code>%s</code>' % (self.format_parameter_name(node, parameter), )
291
+
292
+ def _process_function_call(self, node, match, props):
293
+ func = self._resolve_symbol(props['symbol_name'])
294
+ if func is None:
295
+ return match
296
+
297
+ return self.format_xref(func)
298
+
299
+ def _process_token(self, node, tok):
300
+ kind, match, props = tok
301
+
302
+ dispatch = {
303
+ 'other': self._process_other,
304
+ 'property': self._process_property,
305
+ 'signal': self._process_signal,
306
+ 'type_name': self._process_type_name,
307
+ 'enum_value': self._process_enum_value,
308
+ 'parameter': self._process_parameter,
309
+ 'function_call': self._process_function_call,
310
+ }
311
+
312
+ return dispatch[kind](node, match, props)
313
+
314
+ def get_in_parameters(self, node):
315
+ raise NotImplementedError
316
+
317
+ def format_inline(self, node, para):
318
+ tokens = self._scanner.scan(para)
319
+ words = [self._process_token(node, tok) for tok in tokens]
320
+ return ''.join(words)
321
+
322
+ def format_parameter_name(self, node, parameter):
323
+ if isinstance(parameter.type, ast.Varargs):
324
+ return "..."
325
+ else:
326
+ return parameter.argname
327
+
328
+ def format_function_name(self, func):
329
+ raise NotImplementedError
330
+
331
+ def format_type(self, type_, link=False):
332
+ raise NotImplementedError
333
+
334
+ def format_page_name(self, node):
335
+ if isinstance(node, ast.Namespace):
336
+ return node.name
337
+ elif isinstance(node, ast.Function):
338
+ return self.format_function_name(node)
339
+ elif isinstance(node, ast.Property) and node.parent is not None:
340
+ return '%s:%s' % (self.format_page_name(node.parent), node.name)
341
+ elif isinstance(node, ast.Signal) and node.parent is not None:
342
+ return '%s::%s' % (self.format_page_name(node.parent), node.name)
343
+ elif isinstance(node, ast.VFunction) and node.parent is not None:
344
+ return '%s::%s' % (self.format_page_name(node.parent), node.name)
345
+ elif isinstance(node, ast.Field) and node.parent is not None:
346
+ return '%s->%s' % (self.format_page_name(node.parent), node.name)
347
+ else:
348
+ return make_page_id(node)
349
+
350
+ def format_xref(self, node, **attrdict):
351
+ if node is None or not hasattr(node, 'namespace'):
352
+ attrs = [('xref', 'index')] + attrdict.items()
353
+ return xmlwriter.build_xml_tag('link', attrs)
354
+ elif isinstance(node, ast.Member):
355
+ # Enum/BitField members are linked to the main enum page.
356
+ return self.format_xref(node.parent, **attrdict) + '.' + node.name
357
+ elif node.namespace is self._transformer.namespace:
358
+ return self.format_internal_xref(node, attrdict)
359
+ else:
360
+ return self.format_external_xref(node, attrdict)
361
+
362
+ def format_internal_xref(self, node, attrdict):
363
+ attrs = [('xref', make_page_id(node))] + attrdict.items()
364
+ return xmlwriter.build_xml_tag('link', attrs)
365
+
366
+ def format_external_xref(self, node, attrdict):
367
+ ns = node.namespace
368
+ attrs = [('href', '../%s-%s/%s.html' % (ns.name, str(ns.version),
369
+ make_page_id(node)))]
370
+ attrs += attrdict.items()
371
+ return xmlwriter.build_xml_tag('link', attrs, self.format_page_name(node))
372
+
373
+ def field_is_writable(self, field):
374
+ return True
375
+
376
+ def format_property_flags(self, property_, construct_only=False):
377
+ flags = []
378
+
379
+ if property_.readable and not construct_only:
380
+ flags.append("Read")
381
+ if property_.writable and not construct_only and \
382
+ self.field_is_writable(property_):
383
+ flags.append("Write")
384
+ if isinstance(property_, ast.Property):
385
+ if property_.construct:
386
+ flags.append("Construct")
387
+ if property_.construct_only:
388
+ flags.append("Construct Only")
389
+
390
+ return " / ".join(flags)
391
+
392
+ def to_underscores(self, node):
393
+ if isinstance(node, ast.Property):
394
+ return node.name.replace('-', '_')
395
+ elif node.name:
396
+ return to_underscores(node.name)
397
+ elif isinstance(node, ast.Callback):
398
+ return 'callback'
399
+ elif isinstance(node, ast.Union):
400
+ return 'anonymous_union'
401
+ elif isinstance(node, ast.Field):
402
+ return 'anonymous field'
403
+ else:
404
+ raise Exception('invalid node')
405
+
406
+ def to_lower_camel_case(self, string):
407
+ return string[0].lower() + string[1:]
408
+
409
+ def get_class_hierarchy(self, node):
410
+ assert isinstance(node, ast.Class)
411
+
412
+ parent_chain = [node]
413
+ while node.parent_type:
414
+ node = self._transformer.lookup_typenode(node.parent_type)
415
+ parent_chain.append(node)
416
+
417
+ parent_chain.reverse()
418
+ return parent_chain
419
+
420
+ def format_prerequisites(self, node):
421
+ assert isinstance(node, ast.Interface)
422
+
423
+ if len(node.prerequisites) > 0:
424
+ if len(node.prerequisites) > 1:
425
+ return ', '.join(node.prerequisites[:-1]) + \
426
+ ' and ' + node.prerequisites[-1]
427
+ else:
428
+ return node.prerequisites[0]
429
+ else:
430
+ return 'GObject.Object'
431
+
432
+ def format_known_implementations(self, node):
433
+ assert isinstance(node, ast.Interface)
434
+
435
+ node_name = node.namespace.name + '.' + node.name
436
+ impl = []
437
+
438
+ for c in node.namespace.itervalues():
439
+ if not isinstance(c, ast.Class):
440
+ continue
441
+ for implemented in c.interfaces:
442
+ if implemented.target_giname == node_name:
443
+ impl.append(c)
444
+ break
445
+
446
+ if len(impl) == 0:
447
+ return 'None'
448
+ else:
449
+ out = '%s is implemented by ' % (node.name,)
450
+ if len(impl) == 1:
451
+ return out + impl[0].name
452
+ else:
453
+ return out + ', '.join(i.name for i in impl[:-1]) + \
454
+ ' and ' + impl[-1].name
455
+
456
+
457
+ class DocFormatterC(DocFormatter):
458
+ language = "C"
459
+ mime_type = "text/x-csrc"
460
+
461
+ fundamentals = {
462
+ "TRUE": "TRUE",
463
+ "FALSE": "FALSE",
464
+ "NULL": "NULL",
465
+ }
466
+
467
+ def format_type(self, type_, link=False):
468
+ if isinstance(type_, ast.Array):
469
+ return self.format_type(type_.element_type) + '*'
470
+ elif type_.ctype is not None:
471
+ return type_.ctype
472
+ elif type_.target_fundamental:
473
+ return type_.target_fundamental
474
+ else:
475
+ node = self._transformer.lookup_typenode(type_)
476
+ return getattr(node, 'ctype')
477
+
478
+ def format_function_name(self, func):
479
+ if isinstance(func, ast.Function):
480
+ return func.symbol
481
+ else:
482
+ return func.name
483
+
484
+ def get_in_parameters(self, node):
485
+ return node.all_parameters
486
+
487
+
488
+ class DocFormatterIntrospectableBase(DocFormatter):
489
+ def should_render_node(self, node):
490
+ if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None:
491
+ return False
492
+
493
+ if not getattr(node, "introspectable", True):
494
+ return False
495
+
496
+ if isinstance(node, ast.Function) and node.shadowed_by is not None:
497
+ return False
498
+
499
+ return super(DocFormatterIntrospectableBase, self).should_render_node(node)
500
+
501
+
502
+ class DocFormatterPython(DocFormatterIntrospectableBase):
503
+ language = "Python"
504
+ mime_type = "text/python"
505
+
506
+ fundamentals = {
507
+ "TRUE": "True",
508
+ "FALSE": "False",
509
+ "NULL": "None",
510
+ }
511
+
512
+ def should_render_node(self, node):
513
+ if getattr(node, "is_constructor", False):
514
+ return False
515
+
516
+ return super(DocFormatterPython, self).should_render_node(node)
517
+
518
+ def is_method(self, node):
519
+ if getattr(node, "is_method", False):
520
+ return True
521
+
522
+ if isinstance(node, ast.VFunction):
523
+ return True
524
+
525
+ return False
526
+
527
+ def format_parameter_name(self, node, parameter):
528
+ # Force "self" for the first parameter of a method
529
+ if self.is_method(node) and parameter is node.instance_parameter:
530
+ return "self"
531
+ elif isinstance(parameter.type, ast.Varargs):
532
+ return "..."
533
+ else:
534
+ return parameter.argname
535
+
536
+ def format_fundamental_type(self, name):
537
+ fundamental_types = {
538
+ "utf8": "unicode",
539
+ "gunichar": "unicode",
540
+ "gchar": "str",
541
+ "guchar": "str",
542
+ "gboolean": "bool",
543
+ "gint": "int",
544
+ "guint": "int",
545
+ "glong": "int",
546
+ "gulong": "int",
547
+ "gint64": "int",
548
+ "guint64": "int",
549
+ "gfloat": "float",
550
+ "gdouble": "float",
551
+ "gchararray": "str",
552
+ "GParam": "GLib.Param",
553
+ "PyObject": "object",
554
+ "GStrv": "[str]",
555
+ "GVariant": "GLib.Variant"}
556
+
557
+ return fundamental_types.get(name, name)
558
+
559
+ def format_type(self, type_, link=False):
560
+ if isinstance(type_, (ast.List, ast.Array)):
561
+ return '[' + self.format_type(type_.element_type) + ']'
562
+ elif isinstance(type_, ast.Map):
563
+ return '{%s: %s}' % (self.format_type(type_.key_type),
564
+ self.format_type(type_.value_type))
565
+ elif type_.target_giname is not None:
566
+ return type_.target_giname
567
+ else:
568
+ return self.format_fundamental_type(type_.target_fundamental)
569
+
570
+ def format_function_name(self, func):
571
+ if func.parent is not None:
572
+ return "%s.%s" % (self.format_page_name(func.parent), func.name)
573
+ else:
574
+ return func.name
575
+
576
+ def get_in_parameters(self, node):
577
+ return node.all_parameters
578
+
579
+
580
+ class DocFormatterGjs(DocFormatterIntrospectableBase):
581
+ language = "Gjs"
582
+ mime_type = "text/x-gjs"
583
+
584
+ fundamentals = {
585
+ "TRUE": "true",
586
+ "FALSE": "false",
587
+ "NULL": "null",
588
+ }
589
+
590
+ def is_method(self, node):
591
+ if getattr(node, "is_method", False):
592
+ return True
593
+
594
+ if isinstance(node, ast.VFunction):
595
+ return True
596
+
597
+ return False
598
+
599
+ def resolve_gboxed_constructor(self, node):
600
+ zero_args_constructor = None
601
+ default_constructor = None
602
+
603
+ introspectable_constructors = \
604
+ filter(lambda c: getattr(c, 'introspectable', True),
605
+ node.constructors)
606
+ for c in introspectable_constructors:
607
+ if zero_args_constructor is None and \
608
+ len(c.parameters) == 0:
609
+ zero_args_constructor = c
610
+ if default_constructor is None and \
611
+ c.name == 'new':
612
+ default_constructor = c
613
+ if default_constructor is None:
614
+ default_constructor = zero_args_constructor
615
+ if default_constructor is None and \
616
+ len(introspectable_constructors) > 0:
617
+ default_constructor = introspectable_constructors[0]
618
+
619
+ node.gjs_default_constructor = default_constructor
620
+ node.gjs_zero_args_constructor = zero_args_constructor
621
+
622
+ def should_render_node(self, node):
623
+ if isinstance(node, (ast.Compound, ast.Boxed)):
624
+ self.resolve_gboxed_constructor(node)
625
+
626
+ if isinstance(node, ast.Compound) and node.disguised and \
627
+ len(node.methods) == len(node.static_methods) == len(node.constructors) == 0:
628
+ return False
629
+
630
+ if isinstance(node, ast.ErrorQuarkFunction):
631
+ return False
632
+ if isinstance(node, ast.Field):
633
+ if node.type is None:
634
+ return False
635
+ if isinstance(node.parent, (ast.Class, ast.Union)):
636
+ return False
637
+ if isinstance(node, ast.Union) and node.name is None:
638
+ return False
639
+ if isinstance(node, ast.Class):
640
+ is_gparam_subclass = False
641
+ if node.parent_type:
642
+ parent = self._transformer.lookup_typenode(node.parent_type)
643
+ while parent:
644
+ if parent.namespace.name == 'GObject' and \
645
+ parent.name == 'ParamSpec':
646
+ is_gparam_subclass = True
647
+ break
648
+ if parent.parent_type is None:
649
+ break
650
+ parent = self._transformer.lookup_typenode(parent.parent_type)
651
+ if is_gparam_subclass:
652
+ return False
653
+
654
+ return super(DocFormatterGjs, self).should_render_node(node)
655
+
656
+ def format_fundamental_type(self, name):
657
+ fundamental_types = {
658
+ "none": "void",
659
+ "gpointer": "void",
660
+ "gboolean": "Boolean",
661
+ "gint8": "Number(gint8)",
662
+ "guint8": "Number(guint8)",
663
+ "gint16": "Number(gint16)",
664
+ "guint16": "Number(guint16)",
665
+ "gint32": "Number(gint32)",
666
+ "guint32": "Number(guint32)",
667
+ "gchar": "Number(gchar)",
668
+ "guchar": "Number(guchar)",
669
+ "gshort": "Number(gshort)",
670
+ "gint": "Number(gint)",
671
+ "guint": "Number(guint)",
672
+ "gfloat": "Number(gfloat)",
673
+ "gdouble": "Number(gdouble)",
674
+ "utf8": "String",
675
+ "gunichar": "String",
676
+ "filename": "String",
677
+ "GType": "GObject.Type",
678
+ "GVariant": "GLib.Variant",
679
+ # These cannot be fully represented in gjs
680
+ "gsize": "Number(gsize)",
681
+ "gssize": "Number(gssize)",
682
+ "gintptr": "Number(gintptr)",
683
+ "guintptr": "Number(guintptr)",
684
+ "glong": "Number(glong)",
685
+ "gulong": "Number(gulong)",
686
+ "gint64": "Number(gint64)",
687
+ "guint64": "Number(guint64)",
688
+ "long double": "Number(long double)",
689
+ "long long": "Number(long long)",
690
+ "unsigned long long": "Number(unsigned long long)"}
691
+
692
+ return fundamental_types.get(name, name)
693
+
694
+ def format_type(self, type_, link=False):
695
+ if isinstance(type_, ast.Array) and \
696
+ type_.element_type.target_fundamental in ('gint8', 'guint8'):
697
+ return 'ByteArray'
698
+ elif isinstance(type_, (ast.List, ast.Array)):
699
+ return 'Array(' + self.format_type(type_.element_type, link) + ')'
700
+ elif isinstance(type_, ast.Map):
701
+ return '{%s: %s}' % (self.format_type(type_.key_type, link),
702
+ self.format_type(type_.value_type, link))
703
+ elif not type_ or type_.target_fundamental == "none":
704
+ return "void"
705
+ elif type_.target_giname is not None:
706
+ giname = type_.target_giname
707
+ if giname in ('GLib.ByteArray', 'GLib.Bytes'):
708
+ return 'ByteArray'
709
+ if giname == 'GObject.Value':
710
+ return 'Any'
711
+ if giname == 'GObject.Closure':
712
+ return 'Function'
713
+ if link:
714
+ nsname = self._transformer.namespace.name
715
+ if giname.startswith(nsname + '.'):
716
+ return '<link xref="%s">%s</link>' % (giname, giname)
717
+ else:
718
+ resolved = self._transformer.lookup_typenode(type_)
719
+ if resolved:
720
+ return self.format_xref(resolved)
721
+ return giname
722
+ else:
723
+ return self.format_fundamental_type(type_.target_fundamental)
724
+
725
+ def format_function_name(self, func):
726
+ name = func.name
727
+ if func.shadows:
728
+ name = func.shadows
729
+
730
+ if func.is_method:
731
+ return "%s.prototype.%s" % (self.format_page_name(func.parent), name)
732
+ elif func.parent is not None:
733
+ return "%s.%s" % (self.format_page_name(func.parent), name)
734
+ else:
735
+ return name
736
+
737
+ def format_page_name(self, node):
738
+ if isinstance(node, (ast.Field, ast.Property)):
739
+ return '%s.%s' % (self.format_page_name(node.parent), self.to_underscores(node))
740
+ else:
741
+ return DocFormatterIntrospectableBase.format_page_name(self, node)
742
+
743
+ def has_any_parameters(self, node):
744
+ return len(node.parameters) > 0 or \
745
+ node.retval.type.target_fundamental != 'none'
746
+
747
+ def get_in_parameters(self, node):
748
+ skip = set()
749
+ for param in node.parameters:
750
+ if param.direction == ast.PARAM_DIRECTION_OUT:
751
+ skip.add(param)
752
+ if param.closure_name is not None:
753
+ skip.add(node.get_parameter(param.closure_name))
754
+ if param.destroy_name is not None:
755
+ skip.add(node.get_parameter(param.destroy_name))
756
+ if isinstance(param.type, ast.Array) and param.type.length_param_name is not None:
757
+ skip.add(node.get_parameter(param.type.length_param_name))
758
+
759
+ params = []
760
+ for param in node.parameters:
761
+ if param not in skip:
762
+ params.append(param)
763
+ return params
764
+
765
+ def get_out_parameters(self, node):
766
+ skip = set()
767
+ for param in node.parameters:
768
+ if param.direction == ast.PARAM_DIRECTION_IN:
769
+ skip.add(param)
770
+ if param.closure_name is not None:
771
+ skip.add(node.get_parameter(param.closure_name))
772
+ if param.destroy_name is not None:
773
+ skip.add(node.get_parameter(param.destroy_name))
774
+ if isinstance(param.type, ast.Array) and param.type.length_param_name is not None:
775
+ skip.add(node.get_parameter(param.type.length_param_name))
776
+
777
+ params = []
778
+ if node.retval.type.target_fundamental != 'none':
779
+ name = 'return_value'
780
+ if node.retval.type.target_fundamental == 'gboolean':
781
+ name = 'ok'
782
+
783
+ ret_param = ast.Parameter(name, node.retval.type,
784
+ ast.PARAM_DIRECTION_OUT)
785
+ ret_param.doc = node.retval.doc
786
+ params.append(ret_param)
787
+ for param in node.parameters:
788
+ if param not in skip:
789
+ params.append(param)
790
+
791
+ if len(params) == 1:
792
+ params[0].argname = 'Returns'
793
+
794
+ return params
795
+
796
+ def format_in_parameters(self, node):
797
+ in_params = self.get_in_parameters(node)
798
+ return ', '.join(('%s: %s' % (p.argname, self.format_type(p.type, True)))
799
+ for p in in_params)
800
+
801
+ def format_out_parameters(self, node):
802
+ out_params = self.get_out_parameters(node)
803
+
804
+ if len(out_params) == 0:
805
+ return 'void'
806
+ elif len(out_params) == 1:
807
+ return self.format_type(out_params[0].type, True)
808
+ else:
809
+ return '[' + ', '.join(('%s: %s' % (p.argname, self.format_type(p.type, True)))
810
+ for p in out_params) + ']'
811
+
812
+ def field_is_writable(self, node):
813
+ if isinstance(node, ast.Field):
814
+ if node.type is None:
815
+ return False
816
+ if node.private:
817
+ return False
818
+ if isinstance(node.parent, ast.Union):
819
+ return False
820
+ if node.type.target_fundamental not in \
821
+ (None, 'none', 'gpointer', 'utf8', 'filename', 'va_list'):
822
+ return True
823
+
824
+ resolved = self._transformer.lookup_typenode(node.type)
825
+ if resolved:
826
+ if isinstance(resolved, ast.Compound) and node.type.ctype[-1] != '*':
827
+ return self._struct_is_simple(resolved)
828
+ elif isinstance(resolved, (ast.Enum, ast.Bitfield)):
829
+ return True
830
+ return False
831
+ else:
832
+ return True
833
+
834
+ def _struct_is_simple(self, node):
835
+ if node.disguised or len(node.fields) == 0:
836
+ return False
837
+
838
+ for f in node.fields:
839
+ if not self.field_is_writable(f):
840
+ return False
841
+ return True
842
+
843
+ def format_gboxed_constructor(self, node):
844
+ if node.namespace.name == 'GLib' and node.name == 'Variant':
845
+ return 'signature: String, value: Any'
846
+
847
+ zero_args_constructor = node.gjs_zero_args_constructor
848
+ default_constructor = node.gjs_default_constructor
849
+
850
+ can_allocate = zero_args_constructor is not None
851
+ if not can_allocate and isinstance(node, ast.Record):
852
+ can_allocate = self._struct_is_simple(node)
853
+
854
+ # Small lie: if can_allocate is False, and
855
+ # default_constructor is None, then you cannot
856
+ # construct the boxed in any way. But let's
857
+ # pretend you can with the regular constructor
858
+ if can_allocate or default_constructor is None:
859
+ if isinstance(node, ast.Compound):
860
+ fields = filter(self.field_is_writable, node.fields)
861
+ out = ''
862
+ if len(fields) > 0:
863
+ out += "{\n"
864
+ for f in fields:
865
+ out += " <link xref='%s.%s-%s'>%s</link>: value\n" % \
866
+ (node.namespace.name, node.name, f.name, f.name)
867
+ out += "}"
868
+ return out
869
+ else:
870
+ return ''
871
+ else:
872
+ construct_params = self.get_in_parameters(default_constructor)
873
+ return ', '.join(('%s: %s' % (p.argname, self.format_type(p.type)))
874
+ for p in construct_params)
875
+
876
+ LANGUAGES = {
877
+ "c": DocFormatterC,
878
+ "python": DocFormatterPython,
879
+ "gjs": DocFormatterGjs,
880
+ }
881
+
882
+
883
+ class DocWriter(object):
884
+ def __init__(self, transformer, language):
885
+ self._transformer = transformer
886
+
887
+ try:
888
+ formatter_class = LANGUAGES[language.lower()]
889
+ except KeyError:
890
+ raise SystemExit("Unsupported language: %s" % (language, ))
891
+
892
+ self._formatter = formatter_class(self._transformer)
893
+ self._language = self._formatter.language
894
+
895
+ self._lookup = self._get_template_lookup()
896
+
897
+ def _get_template_lookup(self):
898
+ if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
899
+ top_srcdir = os.environ['UNINSTALLED_INTROSPECTION_SRCDIR']
900
+ srcdir = os.path.join(top_srcdir, 'giscanner')
901
+ else:
902
+ srcdir = os.path.dirname(__file__)
903
+
904
+ template_dir = os.path.join(srcdir, 'doctemplates')
905
+
906
+ return TemplateLookup(directories=[template_dir],
907
+ module_directory=tempfile.mkdtemp(),
908
+ output_encoding='utf-8')
909
+
910
+ def write(self, output):
911
+ try:
912
+ os.makedirs(output)
913
+ except OSError:
914
+ # directory already made
915
+ pass
916
+
917
+ self._walk_node(output, self._transformer.namespace, [])
918
+ self._transformer.namespace.walk(lambda node, chain: self._walk_node(output, node, chain))
919
+
920
+ def _walk_node(self, output, node, chain):
921
+ if isinstance(node, ast.Function) and node.moved_to is not None:
922
+ return False
923
+ if self._formatter.should_render_node(node):
924
+ self._render_node(node, chain, output)
925
+
926
+ # hack: fields are not Nodes in the ast, so we don't
927
+ # see them in the visit. Handle them manually here
928
+ if isinstance(node, (ast.Compound, ast.Class)):
929
+ chain.append(node)
930
+ for f in node.fields:
931
+ self._walk_node(output, f, chain)
932
+ chain.pop()
933
+ return True
934
+ return False
935
+
936
+ def _render_node(self, node, chain, output):
937
+ namespace = self._transformer.namespace
938
+
939
+ # A bit of a hack...maybe this should be an official API
940
+ node._chain = list(chain)
941
+
942
+ page_kind = get_node_kind(node)
943
+ template_name = '%s/%s.tmpl' % (self._language, page_kind)
944
+ page_id = make_page_id(node)
945
+
946
+ template = self._lookup.get_template(template_name)
947
+ result = template.render(namespace=namespace,
948
+ node=node,
949
+ page_id=page_id,
950
+ page_kind=page_kind,
951
+ formatter=self._formatter,
952
+ ast=ast)
953
+
954
+ output_file_name = os.path.join(os.path.abspath(output),
955
+ page_id + '.page')
956
+ fp = open(output_file_name, 'w')
957
+ fp.write(result)
958
+ fp.close()