Skip to content

Commit

Permalink
Move macro to library
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Apr 14, 2020
1 parent 248a865 commit 3a4bd56
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
Binary file modified lib/passthrough.swagger-1.0.jar
Binary file not shown.
57 changes: 1 addition & 56 deletions process_swagger.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This file is part of the DITA-OT Swagger Plug-in project.
See the accompanying LICENSE file for applicable licenses.
-->
<project name="fox.jason.passthrough.swagger" xmlns:if="ant:if" xmlns:unless="ant:unless">
<project name="fox.jason.passthrough.swagger">

<target name="swagger.css.copy">
<loadfile property="swagger.css" srcFile="${dita.plugin.fox.jason.passthrough.swagger.dir}/resource/swagger.css"/>
Expand All @@ -13,61 +13,6 @@
-->
<target name="swagger.process.pre">
<taskdef resource="fox/jason/swagger/antlib.xml"/>

<!--
Individual file processing for swagger.
Take an input format run swagger against it and convert to DITA
@param src - The input file to convert to DITA
@param dest - The output file location
@param title - The title of the converted file
@param metadata - The metadata of the converted file
-->
<macrodef name="add-swagger-file">
<attribute name="src" />
<attribute name="dest" />
<attribute name="title" />
<attribute name="metadata"/>
<sequential>
<echo if:set="swagger.installed" taskname="swagger" level="info" message="Processing @{src}"/>

<local name="swagger.temp.file"/>
<local name="swagger.result"/>
<local name="swagger.output"/>
<local name="swagger.error"/>
<local name="swagger.isError"/>

<tempfile deleteonexit="true" destdir="${dita.temp.dir}"
property="swagger.temp.file" suffix=""/>

<java taskname="swagger-gen" outputproperty="swagger.output" resultproperty="swagger.result" errorproperty="swagger.error" jar="${dita.plugin.fox.jason.passthrough.swagger.dir}/lib/swagger2markup-cli-1.3.3.jar"
fork="true" failonerror="false" maxmemory="128m">

<arg value="convert"/>
<arg value="-i"/>
<arg value="@{src}"/>
<arg value="-f"/>
<arg value="${swagger.temp.file}"/>
<arg value="-c"/>
<arg value="${dita.plugin.fox.jason.passthrough.swagger.dir}/cfg/config.properties"/>
</java>

<condition property="swagger.isError">
<not>
<equals arg1="${swagger.result}" arg2="0"/>
</not>
</condition>

<echo taskname="swagger-gen" if:set="swagger.isError" level="error" message="${swagger.error}"/>
<dita-ot-fail if:set="swagger.isError" id="SWAG001F">
<param name="1" value="@{src}"/>
</dita-ot-fail>
<format-swagger-markdown file="${swagger.temp.file}.md"/>

<!--copy file="${swagger.temp.file}.md" tofile="${output.dir}/test.md"/-->
<add-pandoc-file src="${swagger.temp.file}.md" dest="@{dest}" title="@{title}" metadata="@{metadata}"/>
</sequential>
</macrodef>
</target>


Expand Down
57 changes: 56 additions & 1 deletion src/main/resources/fox/jason/swagger/antlib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This file is part of the DITA-OT Splash Screen Plug-in project.
See the accompanying LICENSE file for applicable licenses.
-->
<antlib>
<antlib xmlns:if="ant:if" xmlns:unless="ant:unless">

<!--
Expand All @@ -15,4 +15,59 @@
-->
<taskdef classname="fox.jason.passthrough.tasks.FormatMarkdownTask" name="format-swagger-markdown"/>

<!--
Individual file processing for swagger.
Take an input format run swagger against it and convert to DITA
@param src - The input file to convert to DITA
@param dest - The output file location
@param title - The title of the converted file
@param metadata - The metadata of the converted file
-->
<macrodef name="add-swagger-file">
<attribute name="src" />
<attribute name="dest" />
<attribute name="title" />
<attribute name="metadata"/>
<sequential>
<echo if:set="swagger.installed" taskname="swagger" level="info" message="Processing @{src}"/>

<local name="swagger.temp.file"/>
<local name="swagger.result"/>
<local name="swagger.output"/>
<local name="swagger.error"/>
<local name="swagger.isError"/>

<tempfile deleteonexit="true" destdir="${dita.temp.dir}"
property="swagger.temp.file" suffix=""/>

<java taskname="swagger-gen" outputproperty="swagger.output" resultproperty="swagger.result" errorproperty="swagger.error" jar="${dita.plugin.fox.jason.passthrough.swagger.dir}/lib/swagger2markup-cli-1.3.3.jar"
fork="true" failonerror="false" maxmemory="128m">

<arg value="convert"/>
<arg value="-i"/>
<arg value="@{src}"/>
<arg value="-f"/>
<arg value="${swagger.temp.file}"/>
<arg value="-c"/>
<arg value="${dita.plugin.fox.jason.passthrough.swagger.dir}/cfg/config.properties"/>
</java>

<condition property="swagger.isError">
<not>
<equals arg1="${swagger.result}" arg2="0"/>
</not>
</condition>

<echo taskname="swagger-gen" if:set="swagger.isError" level="error" message="${swagger.error}"/>
<dita-ot-fail if:set="swagger.isError" id="SWAG001F">
<param name="1" value="@{src}"/>
</dita-ot-fail>
<format-swagger-markdown file="${swagger.temp.file}.md"/>

<!--copy file="${swagger.temp.file}.md" tofile="${output.dir}/test.md"/-->
<add-pandoc-file src="${swagger.temp.file}.md" dest="@{dest}" title="@{title}" metadata="@{metadata}"/>
</sequential>
</macrodef>

</antlib>

0 comments on commit 3a4bd56

Please sign in to comment.