Skip to content

Commit

Permalink
Updated documentation (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhaufe authored Jan 15, 2024
1 parent 6b5299b commit f0f256f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 113 deletions.
96 changes: 0 additions & 96 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,99 +7,3 @@ for commercial and other private use. A CLA is also not currently defined.

When these issues are resolved and more formalized contributions will then be accepted with the
appropriate caveats.

## Building and Editing

## Getting Started

- Clone the repository

```batch
git clone --depth=1 ...
```

- Install dependencies

```batch
cd <project_name>
npm install
```

- Build

```batch
npm run build
```

## Project Structure

| Name | Description |
|:------------------|:--------------------------------------------------------------------------------------------------------------|
| .cache | Cache directory generated by [Parcel](https://parceljs.org/) |
| .vscode | Settings for VS Code |
| azure | Build pipeline definitions used by Azure Devops |
| dist | Contains the compiled output of the build |
| docs | Library documentation |
| node_modules | node package dependencies |
| src | Contains the source code that will be compiled to the `dist` dir |
| .editorconfig | Config settings for [EditorConfig](https://editorconfig.org/) IDE code style checking |
| .gitignore | Specifies files untracked by version control |
| .npmrc | npm config settings |
| LICENSE | GNU General Public License v2.0 only |
| package-lock.json | Autogenerated [meta-manifest](https://docs.npmjs.com/files/package-lock.json) of package.json |
| package.json | [Node Package configuration](https://docs.npmjs.com/files/package.json) settings with related build scripts |
| README.md | The current file. A high level overview of the library |
| tsconfig.json | Config settings for compiling TypeScript code |
| tslint.json | Config settings for TSLint code style checking |

## Build and Test

To build and test this library locally you will need the following:

- [VS Code](https://code.visualstudio.com/)

- Install the recommended extensions

- A [active](https://github.com/nodejs/Release) version of [Node.js](https://nodejs.org/en/)
- With a corresponding [npm installation](https://www.npmjs.com/get-npm)

| Npm Script | Description |
|:--------------|:------------|
| `build` | Performs a full build of the library including type generation and linting. Outputs to the `dist` folder |
| `build-nofix` | Perfoms the sames steps as `build` except that `lint-nofix` will be executed. |
| `build-types` | Generates type definitions for the library in the `dist` folder |
| `clean` | deletes the `dist` folder |
| `clean-full` | deletes the `dist`, `node_modules`, and `.cache` folders |
| `debug` | Starts debugger |
| `lint` | Performs linting and type checking of the library |
| `lint-nofix` | Performs linting but will not autofix problems. |
| `test` | Executes unit tests |
| `type-check` | Performs type checking |

## Dependencies

Dependencies are managed through `package.json`. There are no runtime dependencies.
The development dependencies are as follows:

| Package | Description | License |
|:------------------------------------------|:----------------------------------------------|--------------|
| `@types/jest` | Type definitions for `ts-jest` support | MIT |
| `@types/node` | Type definitions for node. (used for build) | MIT |
| `@typescript-eslint/eslint-plugin` | Type definitions for ESLint | MIT |
| `@typescript-eslint/parser` | Type definitions for ESLint parser | BSD-2-Clause |
| `eslint` | ECMAScript linting library | MIT |
| `eslint-plugin-header` | ESLint extension for linting file headers | MIT |
| `eslint-plugin-import` | ESLint extension for linting imports | MIT |
| `jest` | JavaScript Unit testing library | MIT |
| `jest-junit` | Jest extension for JUnit reporting | Apache-2.0 |
| `rimraf` | Cross platform lib for deleting files/folders | ISC |
| `ts-jest` | TypeScript support for `jest` | MIT |
| `ts-loader` | TypeScript loader for Webpack | MIT |
| `typescript` | TypeScript compiler | Apache-2.0 |
| `webpack` | Module bundler | MIT |
| `webpack-cli` | Command line library for WebPack | MIT |

If you're using Windows and a newer version of NodeJS then you may additionally
need to run the following command due to a transitive dependency on [node-gyp](https://github.com/nodejs/node-gyp):

`npm install -g windows-build-tools`
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Stack<T> implements StackType<T> {
}

top(): T {
return this.#implementation[this.#implementation.length - 1];
return this.#implementation.at(-1);
}
}
```
Expand Down Expand Up @@ -315,20 +315,14 @@ properties with accessors should be used instead. Example:
```ts
@Contracted(pointContract)
class Point2D {
#x: number
#y: number
accessor x: number
accessor y: number

constructor(x: number, y: number) {
super()
this.#x = x
this.#y = y
this.x = x
this.y = y
}

get x(): number { return this.#x }
set x(value: number) { this.#x = value }

get y(): number { return this.#y }
set y(value: number) { this.#y = value }
}
```

Expand All @@ -344,7 +338,7 @@ True assertions do not throw an error. An example of this is given below using a

```typescript
const stackContract = new Contract<StackType<any>>({
[invariants](self) {
[invariant](self) {
return self.isEmpty() == (self.size == 0) &&
self.isFull() == (self.size == self.limit) &&
self.size >= 0 && self.size <= self.limit
Expand Down Expand Up @@ -572,7 +566,7 @@ The remaining arguments of `ensures` reflect the arguments of the associated fea
```typescript
const baseContract = new Contract<Base>({
someMethod: {
ensures(_self, old, x: number){ return 0 <= x && x <= 10 }
ensures(_self, _old, x: number){ return 0 <= x && x <= 10 }
}
})

Expand Down Expand Up @@ -707,7 +701,7 @@ recursion. An example of `retry` usage:
```ts
const studentRepositoryContract = new Contract<StudentRepository>({
getStudent: {
rescue(self, error, [id], retry) {
rescue(_self, error, [id], retry) {
console.error(error)
console.log('Retrying with legacy id...')
retry(`old-${id}`)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@final-hill/decorator-contracts",
"version": "0.25.0",
"version": "0.25.1",
"description": "Code Contracts for TypeScript and ECMAScript classes",
"type": "module",
"exports": {
Expand Down

0 comments on commit f0f256f

Please sign in to comment.