Skip to content
Draft
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
10 changes: 10 additions & 0 deletions .kokoro/docs/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ $PROJECT_DIR/dev/google-cloud docfx \
$STAGING_FLAG \
$VERBOSITY_FLAG

# Add protobuf
PROTOBUF_DIR=$PROJECT_DIR/dev/vendor/google/protobuf
PROTOBUF_VERSION=$(composer info google/protobuf -f json | jq .versions[0])
$PROJECT_DIR/dev/google-cloud docfx \
--path $PROTOBUF_DIR \
--out protobuf-out \
--metadata-version $PROTOBUF_VERSION \
$STAGING_FLAG \
$VERBOSITY_FLAG

# Add product-neutral guides
$PROJECT_DIR/dev/google-cloud docfx \
--generate-product-neutral-guides \
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -856,5 +856,6 @@
},
"bin": [
"Core/bin/google-cloud-batch"
]
],
"minimum-stability": "RC"
Comment on lines +859 to +860
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
],
"minimum-stability": "RC"
]

}
30 changes: 27 additions & 3 deletions dev/src/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class Component
{
const VERSION_REGEX = '/^V([0-9])?(p[0-9])?(beta|alpha)?[0-9]?$/';
private const PROTOBUF = 'google/protobuf';
public const ROOT_DIR = __DIR__ . '/../../';
private string $path;
private string $releaseLevel;
Expand Down Expand Up @@ -188,7 +189,10 @@ private function validateComponentFiles(): void
$this->description = $composerJson['description'];
$this->composerVersion = $composerJson['version'] ?? null;

if (!$repoName = $composerJson['extra']['component']['target'] ?? null) {
if ($this->packageName === Component::PROTOBUF) {
// special handling for protobuf "virtual" package
$repoName = 'protocolbuffers/protobuf';
} elseif (!$repoName = $composerJson['extra']['component']['target'] ?? null) {
if (!str_starts_with($composerJson['homepage'], 'https://github.com/')) {
throw new RuntimeException(
'composer does not contain extra.component.target, and homepage is not a github URL'
Expand All @@ -204,6 +208,13 @@ private function validateComponentFiles(): void
$repoMetadataJson = $repoMetadataFullJson[$this->name];
} elseif (file_exists($repoMetadataPath = $this->path . '/.repo-metadata.json')) {
$repoMetadataJson = json_decode(file_get_contents($repoMetadataPath), true);
} elseif ($this->packageName === Component::PROTOBUF) {
// special handling for protobuf "virtual" package
$repoMetadataJson = [
'release_level' => 'stable',
'client_documentation' => 'https://cloud.google.com/php/docs/reference/auth/latest',
'library_type' => 'CORE',
];
} else {
throw new RuntimeException(sprintf(
'repo metadata not found for component "%s" and no .repo-metadata.json file found in %s',
Expand All @@ -218,16 +229,22 @@ private function validateComponentFiles(): void
$this->name
));
}
if (empty($repoMetadataJson['release_level'])) {
if (empty($repoMetadataJson['client_documentation'])) {
throw new RuntimeException(sprintf(
'repo metadata does not contain "client_documentation" for component "%s"',
$this->name
));
}
if (empty($repoMetadataJson['library_type'])) {
throw new RuntimeException(sprintf(
'repo metadata does not contain "library_type" for component "%s"',
$this->name
));
}
$this->releaseLevel = $repoMetadataJson['release_level'];
$this->clientDocumentation = $repoMetadataJson['client_documentation'];
$this->productDocumentation = $repoMetadataJson['product_documentation'] ?? '';
$this->libraryType = $repoMetadataJson['library_type'];
$this->productDocumentation = $repoMetadataJson['product_documentation'] ?? '';

$namespaces = [];
foreach ($composerJson['autoload']['psr-4'] as $namespace => $dir) {
Expand Down Expand Up @@ -261,13 +278,20 @@ private function validateComponentFiles(): void
$this->componentDependencies[] = new Component('CommonProtos');
}
}
// add protobuf if it's required
if (isset($composerJson['require']['google/protobuf'])) {
$this->componentDependencies[] = new Component('protobuf', self::ROOT_DIR . '/dev/vendor/google/protobuf');
}
}

/**
* Get the contents of VERSION in the component directory
*/
public function getPackageVersion(): string
{
if (!file_exists(sprintf('%s/VERSION', $this->path))) {
return '';
}
return trim(file_get_contents(sprintf('%s/VERSION', $this->path)));
}

Expand Down
3 changes: 0 additions & 3 deletions dev/src/DocFx/Node/XrefTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ private function replaceUidWithLink(string $uid, ?string $name = null): string

// Check for external package namespaces
switch (true) {
case str_starts_with($uid, '\Google\Protobuf\\'):
$extLinkRoot = 'https://protobuf.dev/reference/php/api-docs/';
break;
case 0 === strpos($uid, '\GuzzleHttp\Promise\PromiseInterface'):
$extLinkRoot = 'https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html';
break;
Expand Down
4 changes: 2 additions & 2 deletions dev/tests/fixtures/docfx/Vision/V1.AnnotateFileRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateFileRequest::setFeatures()'
name: setFeatures
Expand Down Expand Up @@ -206,7 +206,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateFileRequest::setPages()'
name: setPages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateFileResponse::setResponses()'
name: setResponses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageRequest::setFeatures()'
name: setFeatures
Expand Down
12 changes: 6 additions & 6 deletions dev/tests/fixtures/docfx/Vision/V1.AnnotateImageResponse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setFaceAnnotations()'
name: setFaceAnnotations
Expand Down Expand Up @@ -173,7 +173,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setLandmarkAnnotations()'
name: setLandmarkAnnotations
Expand Down Expand Up @@ -204,7 +204,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setLogoAnnotations()'
name: setLogoAnnotations
Expand Down Expand Up @@ -235,7 +235,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setLabelAnnotations()'
name: setLabelAnnotations
Expand Down Expand Up @@ -269,7 +269,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setLocalizedObjectAnnotations()'
name: setLocalizedObjectAnnotations
Expand Down Expand Up @@ -303,7 +303,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AnnotateImageResponse::setTextAnnotations()'
name: setTextAnnotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncAnnotateFileRequest::setFeatures()'
name: setFeatures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ items:
description: 'Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.'
-
id: '↳ labels'
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: 'Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::getRequests()'
Expand All @@ -62,7 +62,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setRequests()'
name: setRequests
Expand Down Expand Up @@ -148,7 +148,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest::setLabels()'
name: setLabels
Expand All @@ -168,7 +168,7 @@ items:
parameters:
-
id: var
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: ''
returns:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesResponse::setResponses()'
name: setResponses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ items:
description: 'Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.'
-
id: '↳ labels'
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: 'Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::getRequests()'
Expand All @@ -69,7 +69,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setRequests()'
name: setRequests
Expand Down Expand Up @@ -202,7 +202,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
-
uid: '\Google\Cloud\Vision\V1\AsyncBatchAnnotateImagesRequest::setLabels()'
name: setLabels
Expand All @@ -222,7 +222,7 @@ items:
parameters:
-
id: var
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: ''
returns:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ items:
description: 'Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.'
-
id: '↳ labels'
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: 'Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.'
-
uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::getRequests()'
Expand All @@ -63,7 +63,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setRequests()'
name: setRequests
Expand Down Expand Up @@ -151,7 +151,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
-
uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesRequest::setLabels()'
name: setLabels
Expand All @@ -171,7 +171,7 @@ items:
parameters:
-
id: var
var_type: 'array|<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField">Google\Protobuf\Internal\MapField</a>'
var_type: 'array|<xref uid="\Google\Protobuf\Internal\MapField">Google\Protobuf\Internal\MapField</xref>'
description: ''
returns:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ items:
syntax:
returns:
-
var_type: '<a href="https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/RepeatedField">Google\Protobuf\Internal\RepeatedField</a>'
var_type: '<xref uid="\Google\Protobuf\Internal\RepeatedField">Google\Protobuf\Internal\RepeatedField</xref>'
-
uid: '\Google\Cloud\Vision\V1\BatchAnnotateFilesResponse::setResponses()'
name: setResponses
Expand Down
Loading
Loading