📃 JSDoc for Typescript added

This commit is contained in:
2021-06-17 00:05:30 -07:00
parent b801ce7eb3
commit 64d6f59a9d
13 changed files with 690 additions and 72 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
.idea/ .idea/
.DS_Store .DS_Store
comics/ comics/
docs/
userdata/ userdata/
dist/ dist/
server/ server/

22
jsdoc.json Normal file
View File

@@ -0,0 +1,22 @@
{
"tags": { "allowUnknownTags": true },
"source": {
"include": ["./src/"],
"includePattern": "\\.(jsx|js|ts|tsx)$"
},
"plugins": [
"better-docs/component",
"better-docs/category",
"plugins/markdown",
"node_modules/better-docs/typescript"
],
"templates": { "better-docs": { "name": "My React components" } },
"opts": {
"destination": "docs/",
"readme": "README.md",
"recurse": true,
"encoding": "utf8",
"verbose": true,
"template": "node_modules/better-docs"
}
}

View File

@@ -10,7 +10,8 @@
"client": "webpack serve --mode development --devtool inline-source-map --hot", "client": "webpack serve --mode development --devtool inline-source-map --hot",
"server": "tsc -p tsconfig.server.json && node server/", "server": "tsc -p tsconfig.server.json && node server/",
"dev": "concurrently \"nodemon\" \"npm run client\"", "dev": "concurrently \"nodemon\" \"npm run client\"",
"server-dev": "nodemon" "server-dev": "nodemon",
"docs": "jsdoc -c jsdoc.json"
}, },
"author": "Rishi Ghan", "author": "Rishi Ghan",
"license": "MIT", "license": "MIT",
@@ -26,6 +27,7 @@
"@types/socket.io-client": "^3.0.0", "@types/socket.io-client": "^3.0.0",
"@types/through2": "^2.0.36", "@types/through2": "^2.0.36",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"better-docs": "^2.3.2",
"comlink-loader": "^2.0.0", "comlink-loader": "^2.0.0",
"event-stream": "^4.0.1", "event-stream": "^4.0.1",
"express": "^4.17.1", "express": "^4.17.1",

View File

@@ -24,7 +24,17 @@ export async function walkFolder(path: string): Promise<Array<IFolderData>> {
}) })
.catch((error) => error); .catch((error) => error);
} }
/**
* Renders an entire login page with email and password fields
* using {@link Renderer}.
*
* Used by external plugins
*
* @param {Object} options
* @param {String} options.action login form action
* @param {String} [options.errorMessage] optional messaga
* @return {Promise<string>} HTML of the page
*/
export const fetchComicBookMetadata = (options) => async (dispatch) => { export const fetchComicBookMetadata = (options) => async (dispatch) => {
const extractionOptions = { const extractionOptions = {
sourceFolder: options, sourceFolder: options,

View File

@@ -1,32 +1,31 @@
import * as React from "react"; import * as React from "react";
import { hot } from "react-hot-loader"; import { hot } from "react-hot-loader";
import Dashboard from "./Dashboard"; import Dashboard from "./Dashboard";
import Import from "./Import"; import Import from "./Import";
import { ComicDetail } from "./ComicDetail"; import { ComicDetail } from "./ComicDetail";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom"; import { Switch, Route } from "react-router";
import Navbar from "./Navbar"; import Navbar from "./Navbar";
import "../assets/scss/App.scss"; import "../assets/scss/App.scss";
class App extends React.Component<Record<string, unknown>, undefined> { class App extends React.Component {
public render() { public render() {
return ( return (
<div> <div>
<Router> <Navbar />
<Navbar /> <Switch>
<Switch> <Route exact path="/">
<Route exact path="/"> <Dashboard />
<Dashboard /> </Route>
</Route> <Route path="/import">
<Route path="/import"> <Import path={"./comics"} />
<Import path={"./comics"} /> </Route>
</Route> <Route
<Route path={"/comic/details/:comicObjectId"}
path={"/comic/details/:comicObjectId"} component={ComicDetail}
component={ComicDetail} />
/> </Switch>
</Switch>
</Router>
</div> </div>
); );
} }

View File

@@ -3,12 +3,15 @@ import { useParams } from "react-router-dom";
import axios from "axios"; import axios from "axios";
import Card from "./Card"; import Card from "./Card";
import { isEmpty, isUndefined } from "lodash"; import { isEmpty, isUndefined } from "lodash";
import { IExtractedComicBookCoverFile } from "threetwo-ui-typings";
type ComicDetailProps = {}; type ComicDetailProps = {};
export const ComicDetail = ({}: ComicDetailProps) => { export const ComicDetail = ({}: ComicDetailProps) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [comicDetail, setComicDetail] = useState([]); const [comicDetail, setComicDetail] = useState<{
const { comicObjectId } = useParams(); rawFileDetails: IExtractedComicBookCoverFile;
}>();
const { comicObjectId } = useParams<{ comicObjectId: string }>();
useEffect(() => { useEffect(() => {
axios axios

View File

@@ -1,3 +1,4 @@
//@ts-ignore
import * as React from "react"; import * as React from "react";
import { isUndefined } from "lodash"; import { isUndefined } from "lodash";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -20,11 +21,24 @@ interface IState {
} }
let socket: Socket; let socket: Socket;
class Import extends React.Component<IProps, IState> { class Import extends React.Component<IProps, IState> {
/**
* Returns the average of two numbers.
*
* @remarks
* This method is part of the {@link core-library#Statistics | Statistics subsystem}.
*
* @param x - The first input number
* @param y - The second input number
* @returns The arithmetic mean of `x` and `y`
*
* @beta
*/
constructor(props: IProps) { constructor(props: IProps) {
super(props); super(props);
this.state = { this.state = {
folderWalkResults: [], folderWalkResults: [],
searchPaneIndex: undefined, searchPaneIndex: 0,
fileOps: [],
}; };
} }
@@ -34,15 +48,6 @@ class Import extends React.Component<IProps, IState> {
}); });
} }
/**
* This initializes a socket.io connection instance with supplied configuration
*
* @return {void} A good string
*
* @example
*
* initiateSocketConnection()
*/
public initiateSocketConnection = () => { public initiateSocketConnection = () => {
if (typeof this.props.path !== "undefined") { if (typeof this.props.path !== "undefined") {
socket = io(SOCKET_BASE_URI, { socket = io(SOCKET_BASE_URI, {

View File

@@ -1,9 +1,10 @@
import React from "react"; import React from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { RootState } from "threetwo-ui-typings";
const Navbar: React.FunctionComponent = (props) => { const Navbar: React.FunctionComponent = (props) => {
const socketConnection = useSelector((state) => state.fileOps); const socketConnection = useSelector((state: RootState) => state.fileOps);
return ( return (
<nav className="navbar "> <nav className="navbar ">

View File

@@ -1,7 +1,8 @@
import * as React from "react"; import * as React from "react";
import { render } from "react-dom"; import { render } from "react-dom";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import configureStore from "./store/index"; import { ConnectedRouter } from "connected-react-router";
import configureStore, { history } from "./store/index";
import App from "./components/App"; import App from "./components/App";
const store = configureStore({}); const store = configureStore({});
@@ -9,7 +10,9 @@ const rootEl = document.getElementById("root");
render( render(
<Provider store={store}> <Provider store={store}>
<App history={history} /> <ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</Provider>, </Provider>,
rootEl, rootEl,
); );

View File

@@ -8,7 +8,12 @@ nlp.extend(sentences);
nlp.extend(numbers); nlp.extend(numbers);
nlp.extend(dates); nlp.extend(dates);
export function tokenize(inputString) { /**
* Tokenizes a search string
* @function
* @param {string} inputString - The string used to search against CV, Shortboxed, and other APIs.
*/
export const tokenize = (inputString) => {
const doc = nlp(inputString); const doc = nlp(inputString);
const sentence = doc.sentences().json(); const sentence = doc.sentences().json();
const number = doc.numbers().fractions(); const number = doc.numbers().fractions();
@@ -41,7 +46,7 @@ export function tokenize(inputString) {
}, },
}; };
return queryObject; return queryObject;
} };
export function refineQuery(queryString) { export function refineQuery(queryString) {
const queryObj = tokenize(queryString); const queryObj = tokenize(queryString);

View File

@@ -3,29 +3,20 @@
"$schema": "https://json.schemastore.org/tsconfig", "$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": { "compilerOptions": {
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"target": "es2019", "target": "es2019",
"jsx": "react", "jsx": "react",
"module": "commonjs", "module": "commonjs",
"sourceMap": true, "sourceMap": true,
"outDir": "./dist/", "outDir": "./dist/",
"skipLibCheck": true, "skipLibCheck": true,
"lib": [ "lib": ["dom", "dom.iterable", "esnext", "webworker"]
"dom",
"dom.iterable",
"esnext",
"webworker"
]
}, },
"settings": { "settings": {
"eslint.workingDirectories": [ "eslint.workingDirectories": [
{ "directory": "./node_modules", "changeProcessCWD": true } { "directory": "./node_modules", "changeProcessCWD": true }
] ]
}, },
"exclude": [ "exclude": ["./src/server "],
"./src/server " "include": ["./src/client/*", "./src/client/types/**/*.d.ts"]
], }
"include": [
"./src/client/*",
"./src/client/types/**/*.d.ts"
]
}

620
yarn.lock

File diff suppressed because it is too large Load Diff