stripper.ts typedoc support

This commit is contained in:
Jan Barfuss 2023-12-23 22:34:49 +01:00
parent 5e9a6b12d9
commit 2eaeec2a26
8 changed files with 362 additions and 2 deletions

1
docs/.nojekyll Normal file
View File

@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

20
docs/README.md Normal file
View File

@ -0,0 +1,20 @@
mensa-api / [Exports](modules.md)
# Mensa-API
## Usage
```
npm install
npx tsc
node ./dist/index.js
```
### Dev
```
make up
```
### Prod
```
make up-prod
```

70
docs/modules.md Normal file
View File

@ -0,0 +1,70 @@
[mensa-api](README.md) / Exports
# mensa-api
## Table of contents
### Functions
- [stripCampus](modules.md#stripcampus)
- [stripMensa](modules.md#stripmensa)
## Functions
### stripCampus
**stripCampus**(`html`): `JSON`
This function strips the html from the campus and Bundesland page and returns a JSON object
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `html` | `string` | The html of the campus or Bundesland page |
#### Returns
`JSON`
JSON object
**`Example`**
```ts
stripCampus(html);
```
#### Defined in
[stripper.ts:141](https://github.com/LeRoid-hub/Mensa-API/blob/5e9a6b1/src/stripper.ts#L141)
___
### stripMensa
**stripMensa**(`html`): `string`
This function strips the html from the mensa page and returns a JSON object
#### Parameters
| Name | Type | Description |
| :------ | :------ | :------ |
| `html` | `string` | The html of the mensa page |
#### Returns
`string`
JSON object
**`Example`**
```ts
stripMensa(html);
```
#### Defined in
[stripper.ts:168](https://github.com/LeRoid-hub/Mensa-API/blob/5e9a6b1/src/stripper.ts#L168)

177
package-lock.json generated
View File

@ -24,6 +24,8 @@
"@types/node": "^20.10.5",
"nodemon": "^3.0.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.3"
}
},
@ -239,6 +241,12 @@
"node": ">=0.4.0"
}
},
"node_modules/ansi-sequence-parser": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz",
"integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==",
"dev": true
},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
@ -904,6 +912,27 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/handlebars": {
"version": "4.7.8",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
"dev": true,
"dependencies": {
"minimist": "^1.2.5",
"neo-async": "^2.6.2",
"source-map": "^0.6.1",
"wordwrap": "^1.0.0"
},
"bin": {
"handlebars": "bin/handlebars"
},
"engines": {
"node": ">=0.4.7"
},
"optionalDependencies": {
"uglify-js": "^3.1.4"
}
},
"node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
@ -1062,6 +1091,12 @@
"node": ">=0.12.0"
}
},
"node_modules/jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
"integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==",
"dev": true
},
"node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@ -1074,12 +1109,30 @@
"node": ">=10"
}
},
"node_modules/lunr": {
"version": "2.3.9",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
"dev": true
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true
},
"node_modules/marked": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
"integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
"dev": true,
"bin": {
"marked": "bin/marked.js"
},
"engines": {
"node": ">= 12"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -1143,6 +1196,15 @@
"node": "*"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/morgan": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
@ -1182,6 +1244,12 @@
"node": ">= 0.6"
}
},
"node_modules/neo-async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"node_modules/nodemon": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.2.tgz",
@ -1522,6 +1590,18 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
"node_modules/shiki": {
"version": "0.14.7",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz",
"integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==",
"dev": true,
"dependencies": {
"ansi-sequence-parser": "^1.1.0",
"jsonc-parser": "^3.2.0",
"vscode-oniguruma": "^1.7.0",
"vscode-textmate": "^8.0.0"
}
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@ -1547,6 +1627,15 @@
"node": ">=10"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/statuses": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
@ -1654,6 +1743,63 @@
"node": ">= 0.6"
}
},
"node_modules/typedoc": {
"version": "0.25.4",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.4.tgz",
"integrity": "sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==",
"dev": true,
"dependencies": {
"lunr": "^2.3.9",
"marked": "^4.3.0",
"minimatch": "^9.0.3",
"shiki": "^0.14.1"
},
"bin": {
"typedoc": "bin/typedoc"
},
"engines": {
"node": ">= 16"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x"
}
},
"node_modules/typedoc-plugin-markdown": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz",
"integrity": "sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw==",
"dev": true,
"dependencies": {
"handlebars": "^4.7.7"
},
"peerDependencies": {
"typedoc": ">=0.24.0"
}
},
"node_modules/typedoc/node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/typedoc/node_modules/minimatch": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
"integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
"dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/typescript": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
@ -1667,6 +1813,19 @@
"node": ">=14.17"
}
},
"node_modules/uglify-js": {
"version": "3.17.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz",
"integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==",
"dev": true,
"optional": true,
"bin": {
"uglifyjs": "bin/uglifyjs"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/undefsafe": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
@ -1708,6 +1867,24 @@
"node": ">= 0.8"
}
},
"node_modules/vscode-oniguruma": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
"integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
"dev": true
},
"node_modules/vscode-textmate": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
"integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
"dev": true
},
"node_modules/wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
"dev": true
},
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",

View File

@ -26,6 +26,8 @@
"@types/node": "^20.10.5",
"nodemon": "^3.0.2",
"ts-node": "^10.9.2",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.3"
}
}

View File

@ -1,4 +1,8 @@
// src/index.js
// index.ts
/**
* @file This is the main file of the project.
* @version 1.0.0
*/
import express, { Express, Request, Response} from "express";
import dotenv from "dotenv";
import cors from "cors";

View File

@ -1,16 +1,41 @@
import * as cheerio from 'cheerio';
/**
* This class represents a Campus or Bundesland
*@class campus
*@property {string} name The name of the Campus or Bundesland
*@property {mensa[]} locations The locations of the Campus or Bundesland
*/
class Campus {
name: string;
locations: Mensa[];
/**
* constructor for campus
* @param name The name of the Campus or Bundesland
* @returns Campus
* @example
* let campus = new Campus("Campus");
*/
constructor(name: string) {
this.name = name;
this.locations = [];
}
/**
* This function adds a location to the Campus or Bundesland
* @param mensa The location or to add
* @returns void
* @example
* campus.addMensa(mensa);
*/
addMensa(mensa: Mensa) {
this.locations.push(mensa);
}
/**
* This function returns a string representation of the Campus or Bundesland
*/
toString() {
let str = this.name + "\n";
this.locations.forEach((elem) => {
@ -20,28 +45,63 @@ class Campus {
}
}
/**
* This class represents a mensa
*@class Mensa
*@property {string} name The name of the Mensa
*@property {string} url The url of the mensa
*/
class Mensa {
name: string;
url: string;
/**
* constructor for mensa
* @param name The name of the mensa
* @param url The url of the Mensa
* @example
* let mensa = new Mensa("Mensa", url;
*/
constructor(name: string, url: string) {
this.name = name;
this.url = url;
}
}
/**
* This class represents a menus
*@class menus
*@property {string} name The name of the menus
*@property {meal[]} meals The meals of the menus
*/
class Menu {
name: string;
meals: Meal[];
/**
* constructor for menus
* @param name The name of the menus
*/
constructor(name: string) {
this.name = name;
this.meals = [];
}
/**
* This function adds a meal to the menus
* @param meal The meal to add
* @returns void
* @example
* menu.addMeal(meal);
*/
addMeal(meal: Meal) {
this.meals.push(meal);
}
/**
* This function returns a string representation of the menus
* @returns string
*/
toString() {
let str = this.name + "\n";
this.meals.forEach((elem) => {
@ -56,6 +116,14 @@ class Meal {
price: string;
atributs: string[];
/**
* constructor for meals
* @param name The name of the meal
* @param price The price of the meals
* @param atributs The atributs of the meals
* @example
* let meal = new Meal("Pommes", "2,50€", ["vegan", "vegetarisch"]);
*/
constructor(name: string, price: string, atributs: string[] ) {
this.name = name;
this.price = price;
@ -63,6 +131,13 @@ class Meal {
}
}
/**
* This function strips the html from the campus and Bundesland page and returns a JSON object
* @param html The html of the campus or Bundesland page
* @returns JSON object
* @example
* stripCampus(html);
*/
export function stripCampus(html: string): JSON {
const $ = cheerio.load(html);
@ -83,6 +158,13 @@ export function stripCampus(html: string): JSON {
return JSON.parse(JSON.stringify(ort));
}
/**
* This function strips the html from the mensa page and returns a JSON object
* @param html The html of the mensa page
* @returns JSON object
* @example
* stripMensa(html);
*/
export function stripMensa(html: string): string {
const $ = cheerio.load(html);

View File

@ -105,5 +105,9 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
},
"typedocOptions": {
"entryPoints": ["src/index.ts"],
"out": "docs"
}
}