-
Notifications
You must be signed in to change notification settings - Fork 0
/
ac-amd-process-dojov1.xsl
81 lines (67 loc) · 3.28 KB
/
ac-amd-process-dojov1.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Transform js-doc-parse dojov1 output to elisp
This transforms the dojov1 output of js-doc-parse to a simple structure for use in Emacs auto completion.
It lists module ids with either a list of properties and methods or a parameter list string if it's
a function. We don't support properties on functions at the moment.
-->
<xsl:param name="name" select="'unknown'"/>
<xsl:output method="text"/>
<xsl:template match="javascript">
<xsl:text>;; Generated with ac-amd-process-dojov1.xsl ;; Don't change by hand, but regenerate from js-doc-parse documentation.</xsl:text>
<xsl:text> (require 'ac-amd) </xsl:text>
<xsl:text> (defun ac-amd-</xsl:text><xsl:value-of select="$name"/><xsl:text>-completions-setup ()</xsl:text>
<xsl:text> (setq ac-amd-properties (append (list</xsl:text>
<xsl:apply-templates select="object[@type='object']"/>
<xsl:text>) ac-amd-properties))</xsl:text>
<xsl:text> (setq ac-amd-functions (append (list</xsl:text>
<xsl:apply-templates select="object[@type='function']"/>
<xsl:text>) ac-amd-functions))</xsl:text>
<xsl:text> (setq ac-amd-constructors (append (list</xsl:text>
<xsl:apply-templates select="object[@classlike='true']"/>
<xsl:text>) ac-amd-constructors))</xsl:text>
<xsl:text>)</xsl:text>
<xsl:text> (provide 'ac-amd-</xsl:text><xsl:value-of select="$name"/><xsl:text>-completions) </xsl:text>
</xsl:template>
<xsl:template match="object[@type='function']">
<xsl:text> (cons "</xsl:text>
<xsl:value-of select="@location"/>
<xsl:text>" "(</xsl:text>
<xsl:apply-templates select="parameters/parameter"/>
<xsl:text>)")</xsl:text>
</xsl:template>
<xsl:template match="object[@classlike='true']">
<xsl:text> (cons "</xsl:text>
<xsl:value-of select="@location"/>
<xsl:text>" "(</xsl:text>
<xsl:apply-templates select="methods/method[@name='constructor']/parameters/parameter"/>
<xsl:text>)")</xsl:text>
</xsl:template>
<xsl:template match="object[@type='object']">
<xsl:text> (cons "</xsl:text>
<xsl:value-of select="@location"/>
<xsl:text>" (list</xsl:text>
<xsl:apply-templates select="properties/property|methods/method"/>
<xsl:text>))</xsl:text>
</xsl:template>
<xsl:template match="property[not(starts-with(@name,'_'))]">
<xsl:text> "</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>"</xsl:text>
</xsl:template>
<xsl:template match="method[not(starts-with(@name,'_'))]">
<xsl:text> "</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>(</xsl:text>
<xsl:apply-templates select="parameters/parameter"/>
<xsl:text>)"</xsl:text>
</xsl:template>
<xsl:template match="parameter">
<xsl:if test="@usage='optional'"><xsl:text>_</xsl:text></xsl:if>
<xsl:value-of select="@name"/>
<xsl:if test="@usage='optional'"><xsl:text>_</xsl:text></xsl:if>
<xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:template>
<xsl:template match="*">
</xsl:template>
</xsl:transform>