Skip to content

Commit 1dd5860

Browse files
authored
fix(storage-control): Update jsdocs headers in v2 clients to include … (#7851)
* fix(storage-control): Update jsdocs headers in v2 clients to include internal to avoid generating docs * don't strip internal from the .d.ts
1 parent 91666d0 commit 1dd5860

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

packages/google-storage-control/src/util/sample_fix_utils.ts renamed to packages/google-storage-control/src/util/samples_and_doc_fix_utils.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import * as fs from 'fs';
1616
import * as path from 'path';
1717

18+
/**
19+
* Updates generated samples by replacing storage with storage-control imports and initializations.
20+
*/
1821
export function updateSamples() {
1922
const dirPath = path.join(
2023
__dirname,
@@ -71,3 +74,36 @@ export function updateSamples() {
7174
}
7275
}
7376
}
77+
78+
/**
79+
* Appends the @internal tag to the class level documentation headers of generated clients.
80+
* This ensures that the docs pipeline ignores these classes when generating documentation.
81+
*/
82+
export function fixDocsHeaders() {
83+
const dirPath = path.join(__dirname, '..', 'v2');
84+
const files = ['storage_client.ts', 'storage_control_client.ts'];
85+
86+
for (const file of files) {
87+
const filePath = path.join(dirPath, file);
88+
if (!fs.existsSync(filePath)) {
89+
continue;
90+
}
91+
92+
let content = fs.readFileSync(filePath, 'utf8');
93+
94+
// Check if @internal is already present in the block to prevent duplicate additions
95+
const replaceRegex = /\* @memberof v2\n \*\/(?!\s*export class)/g;
96+
97+
// We want to target the class documentation block that ends with `* @memberof v2\n */\nexport class `
98+
// and replace it with `* @memberof v2\n * @internal\n */\nexport class `
99+
const classDocRegex = /(\* @memberof v2\n) \*\/\nexport class /g;
100+
101+
if (classDocRegex.test(content)) {
102+
content = content.replace(classDocRegex, '$1 * @internal\n */\nexport class ');
103+
fs.writeFileSync(filePath, content);
104+
console.log(`Successfully added @internal to doc header in: ${filePath}`);
105+
} else {
106+
console.log(`Did not find the expected doc header format in: ${filePath}`);
107+
}
108+
}
109+
}

packages/google-storage-control/src/util/storage_control_utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ import {
2020
} from './proto_utils';
2121
import {buildOutput} from './uber_client_builder';
2222
import {fixIndexFile, fixV2Index} from './index_fix_utils';
23-
import {updateSamples} from './sample_fix_utils';
23+
import {updateSamples, fixDocsHeaders} from './samples_and_doc_fix_utils';
2424

2525
async function main() {
2626
fixIndexFile('src/index.ts');
2727
fixV2Index('v2/index.ts');
2828
cleanObjectReferences(filesToUpdate, replacements);
2929
updateSamples();
30+
fixDocsHeaders();
3031
const finaloutput = await buildOutput();
3132
fs.writeFile('../storage_control_client.ts', finaloutput, err => {
3233
if (err) throw err;

packages/google-storage-control/src/v2/storage_client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const version = require('../../../package.json').version;
6868
* any other character (no special directory semantics).
6969
* @class
7070
* @memberof v2
71+
* @internal
7172
*/
7273
export class StorageClient {
7374
private _terminated = false;

packages/google-storage-control/src/v2/storage_control_client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const version = require('../../../package.json').version;
4545
* StorageControl service includes selected control plane operations.
4646
* @class
4747
* @memberof v2
48+
* @internal
4849
*/
4950
export class StorageControlClient {
5051
private _terminated = false;

packages/google-storage-control/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lib": [
88
"es2023",
99
"dom"
10-
]
10+
],
11+
"stripInternal": false
1112
},
1213
"include": [
1314
"src/*.ts",

0 commit comments

Comments
 (0)