FSN#32930 API Documentatie genereren

svn path=/Website/trunk/; revision=25831
This commit is contained in:
Jos Groot Lipman
2015-08-04 10:51:30 +00:00
parent c069315ed6
commit d6952e7992
5 changed files with 96 additions and 2 deletions

View File

@@ -331,7 +331,8 @@ api2_rest = {
style.resolveExternals = false;
if (Request.QueryString("debug").Count == 0)
{
style.load(Server.MapPath(rooturl + "/appl/api2/reference.xsl")); // De stylesheet laden. API's redeneren vanuit de root
var xslname = model.xslname || "reference.xsl";
style.load(Server.MapPath(rooturl + "/appl/api2/" + xslname)); // De stylesheet laden. API's redeneren vanuit de root
var str_antwoord = xml_antwoord.transformNode(style); // terugstoppen in antwoord
}
else

25
APPL/API2/api_doc.asp Normal file
View File

@@ -0,0 +1,25 @@
<%@ language = "JavaScript" %>
<% /*
$Revision$
$Id$
File: default.asp
Description:
Parameters:
Context: Documentatie van de api's
Notes: Via /api2/doc.doc
*/
DOCTYPE_Disable = true;
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
THIS_FILE = "appl/api/api_doc.asp";
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./api2_rest.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="./model_doc.inc" -->
<%
api2_rest.process(model_doc);
%>

35
APPL/API2/model_doc.inc Normal file
View File

@@ -0,0 +1,35 @@
<% /*
$Revision$
$Id$
File: model_doc.inc
Description: Doc model.
Parameters:
Context:
Notes:
*/
%>
<!-- #include file="model_apis.inc"-->
<%
function model_doc()
{
this.table = "apis";
this.primary = "id";
this.records_name = "apis";
this.record_name = "api";
var apis = model_apis.REST_GET({});
this.fields = {};
for (var i = 0; i < apis.length; i++)
{
this.fields[ apis[i].id ] = { label: apis[i].id };
}
this.REST_GET = generic_REST_GET(this, {});
this.xslname = "model_doc.xsl";
}
%>

View File

@@ -12,15 +12,39 @@
<h1>API reference <xsl:value-of select="/api/records_name"/></h1>
Record name: <xsl:value-of select="/api/record_name"/><br />
Records name: <xsl:value-of select="/api/records_name"/><br />
<h2>Parameters</h2>
<xsl:element name="ul">
<xsl:element name="li">
include
<xsl:element name="ul">
<xsl:for-each select="/api/includes/*">
<xsl:element name="li">
<xsl:element name="a">
<xsl:attribute name="href">../api2/<xsl:value-of select="local-name()"/>.doc</xsl:attribute>
<xsl:value-of select="local-name()"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:element>
<h2>Example:</h2>
<div class="sample">
GET /api2/<xsl:value-of select="/api/records_name"/>.html
GET /api2/<xsl:value-of select="/api/records_name"/>.json
</div>
<xsl:element name="a">
<xsl:attribute name="href">../api2/<xsl:value-of select="/api/records_name"/>.html?limit=3</xsl:attribute>
<xsl:attribute name="target">_new</xsl:attribute>
try
</xsl:element>
<div class="sample">
GET /api2/<xsl:value-of select="/api/records_name"/>.xml
</div>
<xsl:element name="a">
<xsl:attribute name="href">../api2/<xsl:value-of select="/api/records_name"/>.xml?limit=3</xsl:attribute>
<xsl:attribute name="target">_new</xsl:attribute>
try
</xsl:element>
<h2>Fields list</h2>
<xsl:for-each select="/api/fields/*">
<h3>Field: <xsl:value-of select="local-name()"/></h3>

View File

@@ -9,6 +9,15 @@
<match url="^api2/([a-z0-9_]+)/(\d+)/attachments/(.*)/(.*)/?" />
<action type="Rewrite" url="default.asp?mode=attachment&amp;api2={R:1}&amp;id={R:2}&amp;subfolder={R:3}&amp;filename={UrlEncode:{R:4}}" appendQueryString="true" />
</rule>
<!-- /api2/buildings/ /default.asp?api2=doc&format=doc -->
<rule name="Add trailing slash" stopProcessing="true">
<match url="^api2$" />
<action type="Redirect" redirectType="Permanent" url="api2/" />
</rule>
<rule name="api2doc" stopProcessing="true">
<match url="^api2/$" />
<action type="Rewrite" url="default.asp?api2=doc&amp;format=doc" appendQueryString="true" />
</rule>
<!-- /api2/buildings/1234.xml?... /default.asp?api2=buildings&format=xml&id=1234&... -->
<rule name="api2SingleRecord" stopProcessing="true">
<match url="^api2/([a-z0-9_]+)/(\d+)\.(xml|json|html|api|scf|doc)/?" />