Skip to content

Commit

Permalink
updating to show modules in an application
Browse files Browse the repository at this point in the history
  • Loading branch information
lcahlander committed Dec 30, 2021
1 parent 5b4308e commit c8b6589
Show file tree
Hide file tree
Showing 7 changed files with 3,821 additions and 4,182 deletions.
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>org.xqdoc</groupId>
<artifactId>exist-xqdoc</artifactId>
<version>0.7.0</version>
<version>0.7.1</version>

<name>xqDoc Function Documentation</name>
<description>Application and library to generate and display XQuery function documentation for eXist-db</description>
Expand Down Expand Up @@ -66,6 +66,7 @@

<xqdoc.module.namespace>https://xqdoc.org/exist-db/ns/lib/xqdoc/parse</xqdoc.module.namespace>
<xqdoc.module.java.classname>XQDocModule</xqdoc.module.java.classname>
<antlr4-version>4.9.3</antlr4-version>
</properties>

<dependencies>
Expand All @@ -90,7 +91,7 @@
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.3</version>
<version>${antlr4-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
Expand Down
7,875 changes: 3,709 additions & 4,166 deletions src/main/js/frontend/package-lock.json

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/main/js/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { HashRouter as Router, Route, Routes } from "react-router-dom";
import ApplicationModules from "./ApplicationModules";
import ApplicationModule from "./ApplicationModule";
import ApplicationModuleList from "./ApplicationModuleList";
import LibraryModules from "./LibraryModules";
import LibraryModule from "./LibraryModule";
import RestAPI from "./RestAPI";
Expand All @@ -22,8 +23,18 @@ function App() {
<Route path=":libraryID" element={<LibraryModule />}/>
</Route>
<Route path="/Applications" element={<ApplicationModules />}>
<Route path=":applicationID" element={<ApplicationModule />}/>
<Route path=":applicationID" element={<ApplicationModuleList />}>
<Route path=":moduleID" element={<ApplicationModule />} />
</Route>
</Route>
<Route
path="*"
element={
<main style={{ padding: "1rem" }}>
<p>There's nothing here!</p>
</main>
}
/>
</Route>
</Routes>
</Router>
Expand Down
9 changes: 6 additions & 3 deletions src/main/js/frontend/src/ApplicationModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { useParams } from "react-router-dom";
import './App.css';

function ApplicationModule() {
let {applicationID} = useParams();
let {applicationID, moduleID} = useParams();
return (
<h1>Application {applicationID}</h1>
);
<div>
<h1>{applicationID}</h1>
<h2>{moduleID}</h2>
</div>
)
}

export default ApplicationModule;
63 changes: 63 additions & 0 deletions src/main/js/frontend/src/ApplicationModuleList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'bootstrap/dist/css/bootstrap.min.css';
import React, { useEffect, useState } from 'react';
import {useParams, useNavigate, Outlet} from "react-router-dom";
import ReactMarkdown from "react-markdown";
import './App.css';
import {Button, Card, Spinner} from "react-bootstrap";

function ApplicationModuleList() {
let navigate = useNavigate();
let {applicationID} = useParams();
const [resultData, setResultData] = useState({});
const [loading, setLoading] = useState(false);

useEffect(() => {
setLoading(true);
fetch("/exist/restxq/xqdoc/app/" + applicationID)
.then((response) => response.json())
.then(
(result) => {
setResultData(result);
setLoading(false);
},
(error) => {
setResultData({});
setLoading(false);
}
);
}, [applicationID]);

return (
loading ? <span><Spinner animation="grow" /> Loading</span>
:
<>
<div style={{width: "100%"}}>
<h1>Application {applicationID}</h1>
{
resultData.response ?
resultData.response.map((mod) => {
return (
<Card style={{width: "100%", marginBottom: 5}}>
<Card.Header>{mod.type}</Card.Header>
<Card.Body>
<Card.Title><a onClick={() =>
{
navigate("/Application/" + applicationID + "/" + mod.path.replace("/", "~"))
}
}>{mod.path}</a></Card.Title>
<div style={{width: "100%", minHeight: 50, padding: 3, marginBottom: 3}}>
<ReactMarkdown>{mod.comment ? mod.comment.description : ""}</ReactMarkdown>
</div>
</Card.Body>
</Card>
)
})
: null
}
</div>
<Outlet/>
</>
);
}

export default ApplicationModuleList;
27 changes: 25 additions & 2 deletions src/main/xar-resources/modules/xqdoc-lib.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ in a Polymer 3 webpage.
:)
module namespace xq = "http://xqdoc.org/restxq/resource/xqdoc";
import module namespace xqutil = "https://xqdoc.org/exist-db/ns/lib/xqdoc/util" at "../content/xqdoc-module.xqm";
import module namespace functx = "http://www.functx.com";

declare namespace rest = "http://exquery.org/ns/restxq";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
Expand Down Expand Up @@ -479,9 +480,31 @@ declare
%output:method("json")
function xq:app($appName as xs:string*)
{
array {(
map {
"response":
array {(
for $module in fn:collection($xqutil:XQDOC_ROOT_COLLECTION || "/db/apps/" || $appName)//xqdoc:xqdoc
let $module-comment := $module/xqdoc:module/xqdoc:comment
return
map {
"control": map {
"date": $module/xqdoc:control/xqdoc:date/text(),
"version": $module/xqdoc:control/xqdoc:version/text()
},
"type": $module/xqdoc:module/@type/string(),
"comment": xq:comment($module-comment),
"uri": $module/xqdoc:module/xqdoc:uri/text(),
"name":
if ($module/xqdoc:module/xqdoc:name)
then
$module/xqdoc:module/xqdoc:name/text()
else
fn:false(),
"path": functx:substring-before-last(fn:substring-after(fn:base-uri($module), $xqutil:XQDOC_ROOT_COLLECTION || "/db/apps/" || $appName || "/"), ".xml")
}

)}
)}
}
};

(:~
Expand Down
11 changes: 3 additions & 8 deletions xar-assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,18 @@
<dependencySet>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<version>1.5.0</version>
</dependencySet>
<dependencySet>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.8-1</version>
<version>${antlr4-version}</version>
</dependencySet>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependencySet>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.7</version>
</dependencySet>
<dependencySet>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<version>2.10.13</version>
</dependencySet>
</dependencySets>

Expand Down

0 comments on commit c8b6589

Please sign in to comment.