Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ tmp
# Ignore generated examples

# ignore full spec deref, generate during build instead
data/api/v1/full_spec_deref.json
data/api/v2/full_spec_deref.json

# Ignoring all automated content
temp
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions hugo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ content/en/api/**/*.rs
content/en/api/tsconfig.json

# ignore full spec deref, generate during build instead
data/api/v1/full_spec_deref.json
data/api/v2/full_spec_deref.json
# note: data/api moved to the repo root; see the root .gitignore for its deref entries
static/resources/json/full_spec_v1.json
static/resources/json/full_spec_v2.json

Expand Down
4 changes: 2 additions & 2 deletions hugo/assets/scripts/build-api-derefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const findSpecFiles = () => {

versions.forEach(version => {
const assetsPath = `./assets/api/${version}/full_spec.yaml`;
const dataPath = `./data/api/${version}/full_spec.yaml`;
const dataPath = `../data/api/${version}/full_spec.yaml`;

// Try assets first, fallback to data
if (fs.existsSync(assetsPath)) {
Expand Down Expand Up @@ -62,7 +62,7 @@ const processSpec = async (specPath) => {
if (jsonString === "null" || jsonString === '""' || jsonString.length < 5) {
throw new Error(`Aborting write: generated JSON for ${version} is suspiciously small or null.`);
}
const pathToJson = `./data/api/${version}/full_spec_deref.json`;
const pathToJson = `../data/api/${version}/full_spec_deref.json`;
fs.writeFileSync(pathToJson, jsonString, 'utf8');
console.log(`Written dereferenced spec to: ${pathToJson}`);

Expand Down
10 changes: 5 additions & 5 deletions hugo/assets/scripts/build-api-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ const createTranslations = (apiYaml, deref, apiVersion) => {
return {[name]: {"name": tag.name, "description": tag.description}};
}).reduce((obj, item) => ({...obj, ...item}) ,{});

const tagsFilePath = `./data/api/${apiVersion}/translate_tags.json`;
const tagsFilePath = `../data/api/${apiVersion}/translate_tags.json`;
fs.writeFileSync(tagsFilePath, safeJsonStringify(tags, null, 2), 'utf8');

const actions = {};
Expand Down Expand Up @@ -1062,14 +1062,14 @@ const createTranslations = (apiYaml, deref, apiVersion) => {
actions[action.operationId] = item;
});
});
const actionsFilePath = `./data/api/${apiVersion}/translate_actions.json`;
const actionsFilePath = `../data/api/${apiVersion}/translate_actions.json`;
fs.writeFileSync(actionsFilePath, safeJsonStringify(actions, null, 2), 'utf8');
};


/**
* Takes an array of spec file paths and processes them
* @param {array} specs - array of strings with path to spec e.g ['./data/api/v2/full_spec.yaml']
* @param {array} specs - array of strings with path to spec e.g ['../data/api/v2/full_spec.yaml']
*/
const processSpecs = (specs) => {
specs
Expand All @@ -1079,7 +1079,7 @@ const processSpecs = (specs) => {
.then((deref) => {
const version = spec.split('/')[3];
const jsonString = safeJsonStringify(deref, null, 2);
const pathToJson = `./data/api/${version}/full_spec_deref.json`;
const pathToJson = `../data/api/${version}/full_spec_deref.json`;
// we do not write the full spec here anymore to avoid committing to repo, see build-api-derefs.js
// fs.writeFileSync(pathToJson, jsonString, 'utf8');

Expand Down Expand Up @@ -1132,7 +1132,7 @@ const findSpecFiles = () => {

versions.forEach(version => {
const assetsPath = `./assets/api/${version}/full_spec.yaml`;
const dataPath = `./data/api/${version}/full_spec.yaml`;
const dataPath = `../data/api/${version}/full_spec.yaml`;

// Try assets first, fallback to data
if (fs.existsSync(assetsPath)) {
Expand Down
10 changes: 5 additions & 5 deletions hugo/assets/scripts/build-reference-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ const createTranslations = (apiYaml, deref, apiVersion) => {
return {[name]: {"name": tag.name, "description": tag.description}};
}).reduce((obj, item) => ({...obj, ...item}) ,{});

const tagsFilePath = `./data/api/${apiVersion}/translate_tags.json`;
const tagsFilePath = `../data/api/${apiVersion}/translate_tags.json`;
fs.writeFileSync(tagsFilePath, safeJsonStringify(tags, null, 2), 'utf8');

const actions = {};
Expand Down Expand Up @@ -1113,14 +1113,14 @@ const createTranslations = (apiYaml, deref, apiVersion) => {
actions[action.operationId] = item;
});
});
const actionsFilePath = `./data/api/${apiVersion}/translate_actions.json`;
const actionsFilePath = `../data/api/${apiVersion}/translate_actions.json`;
fs.writeFileSync(actionsFilePath, safeJsonStringify(actions, null, 2), 'utf8');
};


/**
* Takes an array of spec file paths and processes them
* @param {array} specs - array of strings with path to spec e.g ['./data/api/v2/full_spec.yaml']
* @param {array} specs - array of strings with path to spec e.g ['../data/api/v2/full_spec.yaml']
*/
const processSpecs = (specs) => {
specs
Expand All @@ -1130,7 +1130,7 @@ const processSpecs = (specs) => {
.then((deref) => {
const version = spec.split('/')[3];
const jsonString = safeJsonStringify(deref, null, 2);
const pathToJson = `./data/api/${version}/full_spec_deref.json`;
const pathToJson = `../data/api/${version}/full_spec_deref.json`;
fs.writeFileSync(pathToJson, jsonString, 'utf8');

// create translation ready datafiles
Expand Down Expand Up @@ -1174,7 +1174,7 @@ const processSpecs = (specs) => {


const init = () => {
const specs = ['./data/api/v1/full_spec.yaml', './data/api/v2/full_spec.yaml'];
const specs = ['../data/api/v1/full_spec.yaml', '../data/api/v2/full_spec.yaml'];
processSpecs(specs);
};

Expand Down
3 changes: 3 additions & 0 deletions hugo/config/_default/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ module:
- 'shortcodes/mdoc/*'
- source: data
target: data
# api data lives at the repo root so non-Hugo consumers (e.g. astro) can read it too
- source: ../data/api
target: data/api
- source: static
target: assets
- source: assets
Expand Down
Loading