Skip to content

Commit

Permalink
TypeDoc documentation updated
Browse files Browse the repository at this point in the history
  • Loading branch information
timashev committed Aug 26, 2022
1 parent cc966f7 commit c6286f7
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 106 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:watch": "npx jest --watch",
"lint": "npx eslint -c .eslintrc.js --ext .ts src",
"build": "npx tsc -p tsconfig-dist.json",
"docs": "typedoc --sourcefile-url-map typedoc-sourcefile-map.json src",
"docs": "typedoc src",
"prepublishOnly": "yarn lint && yarn test",
"prepare": "yarn build"
},
Expand Down Expand Up @@ -58,8 +58,7 @@
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.0.1",
"prettier": "^2.7.1",
"typedoc": "0.21.9",
"typedoc-plugin-sourcefile-url": "^1.0.6",
"typedoc": "^0.23.11",
"typescript": "^4.8.2"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Categories = [UNDEF, FALSE, NEVER, MAYBE, TRUE] as const;
* * `MAYBE` – Uncertain (could be either positive or negative)
* * `TRUE` – Certainly positive
*/
export type Category = typeof Categories[number];
export type Category = 'UNDEF' | 'FALSE' | 'NEVER' | 'MAYBE' | 'TRUE';

/**
* Discrete Logical NOT:
Expand Down
48 changes: 26 additions & 22 deletions src/Logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Fuzzy, not as fNot, and as fAnd, or as fOr, FUZZY_FALSE, FUZZY_TRUE } f
import { Category, UNDEF, FALSE, NEVER, MAYBE, TRUE } from './Category';

/**
* Object-like hash to provide and receive Fuzzy Common Sense logical values where [[Category]]
* Object-like hash to provide and receive Fuzzy Common Sense logical values where {@link Category}
* values are used as keys.
*/
export interface LogicValues {
Expand All @@ -38,7 +38,7 @@ export class Logic {
private values: LogicValues;

/**
* Basic constructor. See [[fromCategory]], [[fromArray]] and [[fromValues]]
* Basic constructor. See {@link fromCategory}, {@link fromArray} and {@link fromValues}
* for more convenient instantiation methods.
*/
public constructor(_undef?: Fuzzy, _false?: Fuzzy, _never?: Fuzzy, _maybe?: Fuzzy, _true?: Fuzzy) {
Expand All @@ -52,8 +52,8 @@ export class Logic {
}

/**
* Creates new [[Logic]] instance with [[FUZZY_TRUE]] value for the specified `category`
* (and [[FUZZY_FALSE]] for all other categories).
* Creates new {@link Logic} instance with {@link Fuzzy.FUZZY_TRUE} value for the specified `category`
* (and {@link Fuzzy.FUZZY_FALSE} for all other categories).
*/
public static fromCategory(category: Category): Logic {
return new Logic(
Expand All @@ -66,23 +66,25 @@ export class Logic {
}

/**
* Creates new [[Logic]] instance from array of [[Fuzzy]] values.
* @param fuzzy The categories order in array is: [[UNDEF]], [[FALSE]], [[NEVER]], [[MAYBE]], [[TRUE]].
* Creates new {@link Logic} instance from array of {@link Fuzzy} values.
* @param fuzzy The categories order in array is: {@link Category.UNDEF}, {@link Category.FALSE},
* {@link Category.NEVER}, {@link Category.MAYBE}, {@link Category.TRUE}.
*/
public static fromArray(fuzzy: Fuzzy[]): Logic {
return new Logic(fuzzy[0], fuzzy[1], fuzzy[2], fuzzy[3], fuzzy[4]);
}

/**
* Creates new [[Logic]] instance from [[LogicValues]].
* Creates new {@link Logic} instance from {@link LogicValues}.
*/
public static fromValues(fuzzy: LogicValues): Logic {
return new Logic(fuzzy.UNDEF, fuzzy.FALSE, fuzzy.NEVER, fuzzy.MAYBE, fuzzy.TRUE);
}

/**
* Retrieves an array of [[Fuzzy]] values.
* @return The categories order in array is: [[UNDEF]], [[FALSE]], [[NEVER]], [[MAYBE]], [[TRUE]].
* Retrieves an array of {@link Fuzzy} values.
* @return The categories order in array is: {@link Category.UNDEF}, {@link Category.FALSE},
* {@link Category.NEVER}, {@link Category.MAYBE}, {@link Category.TRUE}.
*/
public asArray(): Fuzzy[] {
return [
Expand All @@ -95,8 +97,8 @@ export class Logic {
}

/**
* Dominating [[Category]] or `undefined` if none of the categories
* has a value greater than [[FUZZY_FALSE]].
* Dominating {@link Category} or `undefined` if none of the categories
* has a value greater than {@link Fuzzy.FUZZY_FALSE}.
*/
public asCategory(): Category | undefined {
let result: Category = UNDEF;
Expand All @@ -108,8 +110,8 @@ export class Logic {
}

/**
* Retrieves a copy of [[LogicValues]].
* @return A clone, a new instance of [[LogicValues]] created from the values kept internally.
* Retrieves a copy of {@link LogicValues}.
* @return A clone, a new instance of {@link LogicValues} created from the values kept internally.
*/
public asValues(): LogicValues {
return { ...this.values };
Expand All @@ -133,8 +135,9 @@ export class Logic {
}

/**
* String representation of five-dimensional vector of [[Fuzzy]] values.
* The categories order is: [[UNDEF]], [[FALSE]], [[NEVER]], [[MAYBE]], [[TRUE]].
* String representation of five-dimensional vector of {@link Fuzzy} values.
* The categories order is: {@link Category.UNDEF}, {@link Category.FALSE}, {@link Category.NEVER},
* {@link Category.MAYBE}, {@link Category.TRUE}.
*/
public toString(): string {
return `(${this.asArray()
Expand All @@ -143,7 +146,7 @@ export class Logic {
}

/**
* Returns [[Fuzzy]] value of the specified category of this [[Logic]] object.
* Returns {@link Fuzzy} value of the specified category of this {@link Logic} object.
*/
public get(category: Category): Fuzzy {
return this.values[category];
Expand All @@ -160,26 +163,27 @@ export class Logic {
}

/**
* Returns normalized [[Fuzzy]] value for the specified category. See [[normalize]] for details.
* Returns normalized {@link Fuzzy} value for the specified category. See {@link normalize} for details.
*/
public getNormalized(category: Category): Fuzzy {
return this.values[category] / this.normalizer();
}

/**
* If original values are not normalized, returns new Logic object with normalized [[Logic]] value,
* If original values are not normalized, returns new Logic object with normalized {@link Logic} value,
* otherwise return the same object.
*
* The [[Logic]] value is normalized if and only if the sum of [[Fuzzy]] values of all categories
* equals to `1.0` (or `0.0` if there are no categories with [[Fuzzy]] value greater than [[FUZZY_FALSE]]).
* The {@link Logic} value is normalized if and only if the sum of {@link Fuzzy} values of all categories
* equals to `1.0` (or `0.0` if there are no categories with {@link Fuzzy} value greater than
* {@link Fuzzy.FUZZY_FALSE}).
*/
public normalize(): Logic {
const normalizer = this.normalizer();
return Math.abs(normalizer - FUZZY_TRUE) < 1e-8 ? this : this.multiply(FUZZY_TRUE / normalizer);
}

/**
* Checks that at least one of the categories has non-zero [[Fuzzy]] value.
* Checks that at least one of the categories has non-zero {@link Fuzzy} value.
*/
public isValid(): boolean {
return this.scalar() > FUZZY_FALSE;
Expand Down Expand Up @@ -399,7 +403,7 @@ export function or(a: Logic, b: Logic): Logic {
* const valueA = value.normalize();
* const valueB = normalize(value);
* ```
* See [[Logic.normalize]] for details.
* See {@link Logic.normalize} for details.
*/
export function normalize(value: Logic): Logic {
if (value && value instanceof Logic) return value.normalize();
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function or(a: Category | Fuzzy | Logic, b: Category | Fuzzy | Logic): Ca
*
* @return For `Fuzzy` value lesser than `0.0` returns `0.0`,
* for `Fuzzy` value greater then `1.0` returns `1.0`, otherwise returns original `Fuzzy` value.
* See [[Logic]] for details on Fuzzy Human Logic values normalization.
* See {@link Logic} for details on Fuzzy Human Logic values normalization.
*/
export function normalize(value: Fuzzy): Fuzzy;
export function normalize(value: Logic): Logic;
Expand Down
6 changes: 0 additions & 6 deletions typedoc-sourcefile-map.json

This file was deleted.

5 changes: 4 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"excludePrivate": true,
"excludeProtected": true,
"excludeExternals": true,
"githubPages": false,
"entryPointStrategy": "expand",
"categorizeByGroup": false,
"gitRevision": "master",
"exclude": "**/*+(.spec).ts"
}

Loading

0 comments on commit c6286f7

Please sign in to comment.