Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to publish documentation #29

Merged
merged 8 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "documentation"

on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run document
- uses: actions/upload-pages-artifact@v3
with:
path: ./docs
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog

## v1.1.0 2024-04-22
### Added
* Adds GitHub Pages with documentation of the package

### Changed
* Changed all documented `@alpha` release stages changes to `@public`

## v1.0.0 2024-04-15
First stable release! From now on changes to the `fpr-td-gen` will be documented in this changelog and at [GitHub Releases](https://github.com/AgroCares/fpr-td-gen/releases)
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,7 +1,7 @@
{
"name": "@nmi-agro/fpr-td-gen",
"private": false,
"version": "1.0.0",
"version": "1.1.0",
"description": "A generator for the Technical Documentation of the EU Fertilizer Product Regulation",
"keywords": [
"EU",
Expand Down
17 changes: 7 additions & 10 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class Generator {
* @param locale - {@link localesType}
* @param fprVersion - {@link fprVersionType}
* @returns A Generator class with the functions {@link getNextQuestion} and {@link getTechnicalDocumentation}
* @alpha
* @public
*/
packageVersion = '1.0.0'
packageVersion = '1.1.0'
locale: localesType
fprVersion: fprVersionType
pfcDesignation: pfcType = undefined
Expand Down Expand Up @@ -48,7 +48,7 @@ class Generator {

/** Returns the next question
* @returns The question object {@link questionType} for the next question
* @alpha
* @public
*/
getNextQuestion (): questionType {
if (!this.allQuestionsAnswered()) {
Expand All @@ -62,7 +62,7 @@ class Generator {

/** Returns the tecnhical documentation
* @returns The technical documentation {@link technicalDocumentationType} object for the EU fertilizing product
* @alpha
* @public
*/
getTechnicalDocumentation (): technicalDocumentationType {
return {
Expand All @@ -75,7 +75,7 @@ class Generator {
/**
* Check if all questions have been answered
* @returns true if all questions have been answered, else false
* @alpha
* @public
*/
allQuestionsAnswered (): boolean {
let returnValue: boolean
Expand Down Expand Up @@ -126,7 +126,6 @@ class Generator {
* If the general questions for a FPRversion have been answered, this function returns true.
* @returns boolean
* @internal
* @alpha
*/
generalQuestionsComplete (): boolean {
let returnValue: boolean
Expand Down Expand Up @@ -191,7 +190,7 @@ class Generator {
*
* @param answer - The answer to the question of type {@link answerType}.
* @returns `true` if the answer was successfully saved, and `false` otherwise.
* @alpha
* @public
*/
saveAnswer (answer: answerType): boolean {
/**
Expand Down Expand Up @@ -236,7 +235,6 @@ class Generator {
/** Returns the things that need to be included in the technical documentation of a product
* @returns The list of things that need to be included in the technical documentation of a product
* @internal
* @alpha
*/
getTechnicalDocumentationTaskList (): technicalDocumentationTaskListType {
if (!this.allQuestionsAnswered()) {
Expand Down Expand Up @@ -315,8 +313,7 @@ class Generator {
/** Store the generator as JSON file
* @param filePath - The file path for where to store the properties of the generator. Should have the extension ".json".
* @returns A boolean to indicate if the file has been stored successfully
* @internal
* @alpha
* @public
*/
saveToFile (filePath: string): boolean {
// Check if filePath is actual json and can be stored
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Source code available at https://github.com/AgroCares/fpr-td-gen
* In case you find a bug, please report at https://github.com/AgroCares/fpr-td-gen/issues
*
* @alpha
* @public
* @packageDocumentation
*/

Expand Down
5 changes: 2 additions & 3 deletions src/loadFromFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import crypto from 'node:crypto'
import Generator from './generator'

/** Load from JSON file to generator
* @param filePath - The path to where the JSON file is stored, include the filename. It can be generated using the saveToFile method {@link saveToFile}
* @param filePath - The path to where the JSON file is stored, include the filename. It can be generated using the saveToFile method
* @returns A generator class with the specified properties {@link Generator}
* @internal
* @alpha
* @public
*/
function LoadFromFile (filePath: string): Generator {
// Check if filePath is actual json and can be stored
Expand Down
4 changes: 2 additions & 2 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Question {
* @param locale - {@link localesType}
* @param id - {@link idType}
* @returns A Question class with the function {@link getQuestion}
* @alpha
* @public
*/
locale: localesType
id: idType
Expand Down Expand Up @@ -54,7 +54,7 @@ export class Question {
/**
* Returns a question object
* @returns A question object {@link questionType}
* @alpha
* @public
*/
getQuestion (): questionType {
return this.question
Expand Down
50 changes: 32 additions & 18 deletions src/shared.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The question to be asked
*
* @typeParam askType - The question to be asked
* @alpha
* @public
*/
export type askType = string

Expand All @@ -11,7 +11,7 @@ export type askType = string
*
* @typeParam fprVersionType - The version of the FPR to be used
* @remarks Currently only `FPR 2019/100` is allowed
* @alpha
* @public
*/
export type fprVersionType = 'FPR 2019/1009'

Expand All @@ -20,6 +20,7 @@ export type fprVersionType = 'FPR 2019/1009'
* @remarks generalProductQuestions must be asked for all products,
* cmcQuestions are iterable questions which may be asked for each component,
* blendQuestions are questions specific for fertiling product blends (PFC 7) which do not need to give information on its component materials but on the fertiling products contained within the blend.
* @public
*/
export interface fprType {
fprVersion: fprVersionType
Expand All @@ -32,15 +33,15 @@ export interface fprType {
* The id of the question
*
* @typeParam idType - The id of the question
* @alpha
* @public
*/
export type idType = string

/**
* Helper text of a question
*
* @typeParam helpType - Explains the question in more detail
* @alpha
* @public
*/
export type helpType = string

Expand All @@ -49,23 +50,23 @@ export type helpType = string
*
* @typeParam localesType - The language selected to be used
* @remarks Currently only English ('en') and Dutch are available ('nl')
* @alpha
* @public
*/
export type localesType = 'en' | 'nl'

/**
* Placeholder for answer
*
* @typeParam placeholderType - Provides a placeholder for the answer of a question
* @alpha
* @public
*/
export type placeholderType = string | null

/**
* Available options set for a question
*
* @typeParam optionsSetType - The available options set available to answer a question
* @alpha
* @public
*/
export interface optionsSetType {
value: string
Expand All @@ -76,7 +77,7 @@ export interface optionsSetType {
* Available options for a question
* @typeParam optionsType - The available options available to answer a question
*
* @alpha
* @public
*/
export interface optionsType {
value: string
Expand All @@ -87,7 +88,7 @@ export interface optionsType {
* The question to be asked
*
* @typeParam questionType - The question to be asked
* @alpha
* @public
*/
export interface questionType {
id: idType
Expand All @@ -102,7 +103,7 @@ export interface questionType {
* The question set that contains the details of a question
*
* @typeParam questionSetType - The question set that contains the details of a question
* @internal
* @public
*/
export interface questionSetType {
id: string
Expand All @@ -118,7 +119,7 @@ export interface questionSetType {
* The items that need to be contained in the technical documentation
*
* @typeParam tasklistSetType - The question set that contains the details of a question
* @internal
* @public
*/
export interface tasklistSetType {
taskId: string
Expand All @@ -135,7 +136,7 @@ export interface tasklistSetType {
* A collection of various entries for questionsSet
*
* @typeParam questionSetsType - A collection of various entries for questionsSet {@link questionSetType}
* @internal
* @public
*/
export type questionSetsType = questionSetType[]

Expand All @@ -151,7 +152,7 @@ export type tasklistSetsType = tasklistSetType[]
* The technical documentation of the FPR
*
* @typeParam technicalDocumentationType - The technical documentation of the FPR
* @alpha
* @public
*/
export interface technicalDocumentationType {
locale: localesType
Expand All @@ -164,24 +165,26 @@ export interface technicalDocumentationType {
*
* @typeParam typesType - The type of question
* @remarks Currently only `text`, `select`, `checkbox` and `multitext` are allowed
* @alpha
* @public
*/
export type typesType = 'text' | 'select' | 'checkbox' | 'multitext' | undefined

/**
* The id of the option from a `select` question
*
* @typeParam optionsIdType - The id of the option
* @alpha
* @public
*/
export type optionsIdType = string[] | undefined

/**
* Array of values allowed for PFCs
*
* @public
* @see {@link pfcType}
*/
export const pfcDesignations = [undefined, 'PFC 1.A.I', 'PFC 1.A.II', 'PFC 1.B.I', 'PFC 1.B.II', 'PFC 1.C.I.a.i', 'PFC 1.C.I.a.i.A', 'PFC 1.C.I.a.ii', 'PFC 1.C.I.a.ii.A', 'PFC 1.C.I.b.i', 'PFC 1.C.I.b.ii', 'PFC 1.C.II.a', 'PFC 1.C.II.b', 'PFC 2', 'PFC 3.A', 'PFC 3.B', 'PFC 4', 'PFC 5.A', 'PFC 5.B', 'PFC 5.C', 'PFC 6.A', 'PFC 6.B', 'PFC 7'] as const

/**
* The PFC designation
*
Expand Down Expand Up @@ -210,13 +213,14 @@ export const pfcDesignations = [undefined, 'PFC 1.A.I', 'PFC 1.A.II', 'PFC 1.B.I
* * `PFC 6.A`
* * `PFC 6.B`
* * `PFC 7`
* @alpha
* @public
*/
export type pfcType = typeof pfcDesignations[number]

/**
* Array of values allowed for CMCs
*
* @public
* @see {@link cmcType}
*/
export const cmcDesginations = [undefined, 'CMC 1', 'CMC 2', 'CMC 3', 'CMC 4', 'CMC 5', 'CMC 6', 'CMC 7'] as const
Expand All @@ -234,7 +238,7 @@ export const cmcDesginations = [undefined, 'CMC 1', 'CMC 2', 'CMC 3', 'CMC 4', '
* * `CMC 5`
* * `CMC 6`
* * `CMC 7`
* @alpha
* @public
*/
export type cmcType = typeof cmcDesginations[number]

Expand All @@ -245,16 +249,26 @@ export type answerSet = Map<idType, answerType>
*
* @typeParam answerType - The answer to a question
* @remarks Currently only `string` and `string[]` are allowed
* @alpha
* @public
*/

export type answerType = string | string[] | boolean

/**
* Type of the technicaldocumenatation task list
*
* @typeParam technicalDocumentationTaskListType - An array for {@link technicalDocumentationTask}
* @see {@link technicalDocumentationTask}
* @public
*/
export type technicalDocumentationTaskListType = technicalDocumentationTask[]

/**
* Type of technicalDocumentationTask
*
* typeParam technicalDocumentationTask - An object with the properties of a task for the Technical Documentation
* @public
*/
export interface technicalDocumentationTask {
applicableElement: 'product' | string
taskName: string
Expand Down