Skip to content

Commit

Permalink
Merge branch 'quicker-readme.io-updates' into fixing-all-minor-errors…
Browse files Browse the repository at this point in the history
…-in-open-api
  • Loading branch information
p-zielinski committed Oct 18, 2023
2 parents 0e79034 + b671815 commit fd3e368
Show file tree
Hide file tree
Showing 23 changed files with 583 additions and 158 deletions.
35 changes: 11 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,26 @@ Good practices:
### Development process
- For each change / pull request, create your copy of the current documentation, where you will test changes.
- Create your own branch from `master`,
- Create a draft pull request,
- Go to `Manage Versions` page in readme.io
- Click `Add New Version` from top right corner.
- Select the current public version in `Fork from` field, most likely `2018-08-01`
- Type your version name in `Create version` field following the pattern:
`2018-08-01-{your name}-{pull request number}`
- Create a draft pull request
- Make changes in the repository following patterns and good practices.
- Deploy changes to test your documentation:
- Update tables in markdown tables:
- `npm run build-md-tables-from-openapi`
- `npm run update-md-tables-in-doc`
- from API Reference page in readme dashboard:
- remove Voucherify OpenAPI Definition
- refresh the page and remove `VOUCHERIFY API` category from left sidebar, DO NOT REMOVE `INTRODUCTION` catregory from left sidebar
the existing OpenAPI file and all specification files.
- Deploy OpenAPI file by command `rdme openapi ./reference/OpenAPI.json --version=2018-08-01-{your name}-{pull request number}`, choose `Create a new spec` option. Command most likely will fail with the message: `We're sorry, your upload request timed out. Please try again or split your file up into smaller chunks`, but so far, we see that this operation still works correctly.
- Deploy guides pages: `rdme docs ./docs/guides --version=2018-08-01-{your name}-{pull request number}`
- Deploy api reference pages: `rdme docs ./docs/reference-docs --version=2018-08-01-{your name}-{pull request number}`
- Fix docs order: `npm run readme-fix-docs-order -- --version=v2018-08-01-{your name}-{pull request number}`
- test changes using preview on readme.io
- if changes are fine, then:
- Run `npm run manage-project -- --vt={your name}-{pull request number} --create` - this will create new version project with your tag number.
- Visit url provided at the end of the script run to test changes using preview on readme.io
- If you need to make a change:
- Do changes...
- Run `npm run manage-project -- --vt={your name}-{pull request number} --update`- this will update your version.
- Test changes using preview on readme.io
- If needed - **REPEAT**
- If changes are fine, then:
- Add a note in the changelog.
- `git commit`
- `git push`
- `git commit; git push`
- publish PR


## How to merge PR and update public documentation

- Test changes on readme (you can use the version prepared by the contributor).
- Ensure the changelog was updated.
- Merge PR to `master` branch
- In reamde.io, change the current documentation version from `v2018-08-01` to `v2018-08-01-deprecated-mm-dd-yyyy`
- In readme.io, change the current documentation version from `v2018-08-01` to `v2018-08-01-deprecated-mm-dd-yyyy`
- Change the name of your new release version from `2018-08-01-{your name}-{pull request number}` to `v2018-08-01`

> [!NOTE] Readme.io cache pages for 15 minutes, for only logged out users. If you are logged in, then you will always receive the most recent content.
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Locking-Validation-Session.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Locking Validation Session
excerpt: Temporary lock the voucher's usage until redemption is successful.
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: locking-validation-session
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Loyalty Program.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Loyalty Program
excerpt: null
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: loyalty-program
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Prepaid-Gift-Cards.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Prepaid Gift Cards
excerpt: null
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: prepaid-gift-cards
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Qualifications.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Qualification - Checking eligibility
excerpt: null
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: checking-eligibility
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Referral-Program.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Referral Program
excerpt: null
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: referral-program
type: link
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Stacking-Promotion-Tiers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Stacking Promotion Tiers
excerpt: 'In this tutorial, you will learn how to validate, redeem, and manage promotion stacks using API.'
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: stacking-promotion-tiers
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/campaign_recipes/Transfer-Loyalty-Points.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Transfer Loyalty Points
excerpt: See how to transfer points between loyalty cards.
categorySlug: campaigns-1
categorySlug: campaigns-recipes
slug: transfer-loyalty-points
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/discounts_recipes/Discount-Effects.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Discount Effects
excerpt: The discount effect defines how the discount will be applied to the customer's cart. In this article, we're going to show you how different effects work with discounts.
categorySlug: discounts
categorySlug: discounts-recipes
slug: discount-effects
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/discounts_recipes/Free-Shipping-Discount.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Free shipping disount
excerpt: How to use free shipping discounts?
categorySlug: discounts
categorySlug: discounts-recipes
slug: free-shipping-discount
type: basic
hidden: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Give item(s) for free - unit discount
excerpt: How to add free items to customers' orders?
categorySlug: discounts
categorySlug: discounts-recipes
slug: give-item-for-free-unit-discount
type: basic
hidden: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Product-specific discounts
excerpt: A recipe for using *applicable_to* validation rule
categorySlug: discounts
categorySlug: discounts-recipes
slug: discount-for-particular-product
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/discounts_recipes/Stackable-Discounts-API.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Stackable discounts API
excerpt:
categorySlug: discounts
categorySlug: discounts-recipes
slug: manage-stackable-discounts
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/distributions_recipes/CSV-Export-With-API.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: CSV export with API
excerpt: null
categorySlug: distribution-1
categorySlug: distributions-recipes
slug: csv-export
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/distributions_recipes/Geofencing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Geofencing
excerpt:
categorySlug: distribution-1
categorySlug: distributions-recipes
slug: geofencing
type: link
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/distributions_recipes/Import-Legacy-Codes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Import legacy codes
excerpt: null
categorySlug: distribution-1
categorySlug: distributions-recipes
slug: import-codes
type: basic
hidden: false
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/distributions_recipes/Messaging-Automation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Messaging automation
excerpt: How to set up an automatic promotion delivery for a dynamic customer segment?
categorySlug: distribution-1
categorySlug: distributions-recipes
slug: automatic-delivery
type: basic
hidden: false
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"scripts": {
"update-md-tables-in-doc": "ts-node ./scripts/update-md-tables-in-doc.ts",
"build-md-tables-from-openapi": "ts-node ./scripts/build-md-tables-from-openapi.ts",
"readme-fix-docs-order": "ts-node ./scripts/readme-fix-docs-order.ts",
"remove-stoplight-tags-from-openapi": "ts-node ./scripts/remove-stoplight-tags-from-openapi.ts"
"readme-fix-reference-docs": "ts-node ./scripts/readme-fix-reference-docs.ts",
"remove-stoplight-tags-from-openapi": "ts-node ./scripts/remove-stoplight-tags-from-openapi.ts",
"manage-project": "ts-node ./scripts/manage-project.ts"
},
"dependencies": {
"colors": "^1.4.0",
"dotenv": "^16.3.1",
"markdown-it": "^13.0.2",
"minimist": "^1.2.8",
Expand Down
51 changes: 31 additions & 20 deletions scripts/build-md-tables-from-openapi.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
import * as fs from 'fs/promises'
import path from 'path';
import './globals.t'
import * as openApi from '../reference/OpenAPI.json';
import { mdTables } from './md-tables';
import SchemaToMarkdownTable, {RenderMode, ExamplesRenderedAs} from './src/schema-to-md-table';
import * as fs from "fs/promises";
import path from "path";
import "./globals.t";
import * as openApi from "../reference/OpenAPI.json";
import { mdTables } from "./md-tables";
import SchemaToMarkdownTable, {
RenderMode,
ExamplesRenderedAs,
} from "./src/schema-to-md-table";

const PATH_TO_GERENATED_TABLES = [__dirname, './output'];
const PATH_TO_GERENATED_TABLES = [__dirname, "./output"];

(async () => {
const stm = new SchemaToMarkdownTable(openApi.components.schemas, RenderMode.List, ExamplesRenderedAs.PartOfDescription);
for(const [objectName] of mdTables){
try{
const fileName = `${objectName}.md`;
await fs.writeFile(path.join(...PATH_TO_GERENATED_TABLES, fileName), stm.render(objectName))
console.log(`Generated markdown table in ${fileName}`)
}catch(e){
console.log(`Error for ${objectName}`, e)

}
export const buildMdTablesFromOpenApi = async () => {
const stm = new SchemaToMarkdownTable(
openApi.components.schemas,
RenderMode.List,
ExamplesRenderedAs.PartOfDescription
);
for (const [objectName] of mdTables) {
try {
const fileName = `${objectName}.md`;
await fs.writeFile(
path.join(...PATH_TO_GERENATED_TABLES, fileName),
stm.render(objectName)
);
console.log(`Generated markdown table in ${fileName}`);
} catch (e) {
console.log(`Error for ${objectName}`, e);
}
console.log('done')
})()
}
console.log("done");
};

buildMdTablesFromOpenApi();
Loading

0 comments on commit fd3e368

Please sign in to comment.