X Tutup
Skip to content

Commit 8e92159

Browse files
authored
feat: add docs generation action and fix docs (#1872)
1 parent 8c991eb commit 8e92159

File tree

10 files changed

+123
-6
lines changed

10 files changed

+123
-6
lines changed

.github/actions/docs/entrypoint.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh -l
2+
3+
apt-get update
4+
apt-get install -y git
5+
git reset --hard HEAD
6+
7+
# Required so sami.php is available for previous versions
8+
cp .github/actions/docs/sami.php.dist .github/actions/docs/sami.php
9+
10+
# Run the docs generation command
11+
php vendor/bin/sami.php update .github/actions/docs/sami.php
12+
13+
cd ./.docs
14+
15+
git init
16+
git config user.name "GitHub Actions"
17+
git config user.email "actions@github.com"
18+
19+
git add .
20+
git commit -m "Updating docs"
21+
git push -q https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/${GITHUB_REPOSITORY} HEAD:gh-pages --force

.github/actions/docs/sami.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Sami\RemoteRepository\GitHubRemoteRepository;
4+
use Sami\Sami;
5+
use Sami\Version\GitVersionCollection;
6+
use Symfony\Component\Finder\Finder;
7+
8+
$projectRoot = __DIR__ . '/../../..';
9+
10+
$iterator = Finder::create()
11+
->files()
12+
->name('*.php')
13+
->exclude('vendor')
14+
->exclude('tests')
15+
->in($projectRoot);
16+
17+
$versions = GitVersionCollection::create($projectRoot)
18+
->addFromTags(function($tag) {
19+
return 0 === strpos($tag, 'v2.') && false === strpos($tag, 'RC');
20+
})
21+
->add('master', 'master branch');
22+
23+
return new Sami($iterator, [
24+
'title' => 'Google APIs Client Library for PHP API Reference',
25+
'build_dir' => $projectRoot . '/.docs/%version%',
26+
'cache_dir' => $projectRoot . '/.cache/%version%',
27+
'remote_repository' => new GitHubRemoteRepository('googleapis/google-api-php-client', $projectRoot),
28+
'versions' => $versions
29+
]);

.github/actions/docs/sami.php.dist

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Sami\RemoteRepository\GitHubRemoteRepository;
4+
use Sami\Sami;
5+
use Sami\Version\GitVersionCollection;
6+
use Symfony\Component\Finder\Finder;
7+
8+
$projectRoot = __DIR__ . '/../../..';
9+
10+
$iterator = Finder::create()
11+
->files()
12+
->name('*.php')
13+
->exclude('vendor')
14+
->exclude('tests')
15+
->in($projectRoot);
16+
17+
$versions = GitVersionCollection::create($projectRoot)
18+
->addFromTags(function($tag) {
19+
return 0 === strpos($tag, 'v2.') && false === strpos($tag, 'RC');
20+
})
21+
->add('master', 'master branch');
22+
23+
return new Sami($iterator, [
24+
'title' => 'Google APIs Client Library for PHP API Reference',
25+
'build_dir' => $projectRoot . '/.docs/%version%',
26+
'cache_dir' => $projectRoot . '/.cache/%version%',
27+
'remote_repository' => new GitHubRemoteRepository('googleapis/google-api-php-client', $projectRoot),
28+
'versions' => $versions
29+
]);

.github/workflows/docs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Generate Documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
docs:
11+
name: "Generate Project Documentation"
12+
runs-on: ubuntu-16.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
17+
- name: Install Dependencies
18+
uses: nick-invision/retry@v1
19+
with:
20+
timeout_minutes: 10
21+
max_attempts: 3
22+
command: composer config repositories.sami vcs https://${{ secrets.GITHUB_TOKEN }}@github.com/jdpedrie/sami.git && composer require sami/sami:dev-master && git reset --hard HEAD
23+
- name: Generate and Push Documentation
24+
uses: docker://php:7.3-cli
25+
env:
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
27+
with:
28+
entrypoint: ./.github/actions/docs/entrypoint.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
.github/actions/docs/sami.php
23
phpunit.xml
34
phpcs.xml
45
composer.lock

src/Google/AccessToken/Verify.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public function __construct(
7373
* The audience parameter can be used to control which id tokens are
7474
* accepted. By default, the id token must have been issued to this OAuth2 client.
7575
*
76-
* @param $audience
76+
* @param string $idToken the ID token in JWT format
77+
* @param string $audience Optional. The audience to verify against JWt "aud"
7778
* @return array the token payload, if successful
7879
*/
7980
public function verifyIdToken($idToken, $audience = null)

src/Google/Client.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,11 @@ public function verifyIdToken($idToken = null)
765765
/**
766766
* Set the scopes to be requested. Must be called before createAuthUrl().
767767
* Will remove any previously configured scopes.
768-
* @param string|array $scope_or_scopes, ie: array('https://www.googleapis.com/auth/plus.login',
769-
* 'https://www.googleapis.com/auth/moderator')
768+
* @param string|array $scope_or_scopes, ie:
769+
* array(
770+
* 'https://www.googleapis.com/auth/plus.login',
771+
* 'https://www.googleapis.com/auth/moderator'
772+
* );
770773
*/
771774
public function setScopes($scope_or_scopes)
772775
{
@@ -819,6 +822,7 @@ public function prepareScopes()
819822
* Helper method to execute deferred HTTP requests.
820823
*
821824
* @param $request Psr\Http\Message\RequestInterface|Google_Http_Batch
825+
* @param string $expectedClass
822826
* @throws Google_Exception
823827
* @return object of the type of the expected class or Psr\Http\Message\ResponseInterface.
824828
*/

src/Google/Http/MediaFileUpload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public function getProgress()
114114

115115
/**
116116
* Send the next part of the file to upload.
117-
* @param [$chunk] the next set of bytes to send. If false will used $data passed
118-
* at construct time.
117+
* @param bool $chunk Optional. The next set of bytes to send. If false will
118+
* use $data passed at construct time.
119119
*/
120120
public function nextChunk($chunk = false)
121121
{

src/Google/Http/REST.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Google_Http_REST
3333
*
3434
* @param Google_Client $client
3535
* @param Psr\Http\Message\RequestInterface $req
36+
* @param string $expectedClass
37+
* @param array $config
38+
* @param array $retryMap
3639
* @return array decoded result
3740
* @throws Google_Service_Exception on server side error (ie: not authenticated,
3841
* invalid or malformed post body, invalid url)
@@ -63,6 +66,7 @@ public static function execute(
6366
*
6467
* @param Google_Client $client
6568
* @param Psr\Http\Message\RequestInterface $request
69+
* @param string $expectedClass
6670
* @return array decoded result
6771
* @throws Google_Service_Exception on server side error (ie: not authenticated,
6872
* invalid or malformed post body, invalid url)
@@ -100,6 +104,7 @@ public static function doExecute(ClientInterface $client, RequestInterface $requ
100104
* @throws Google_Service_Exception
101105
* @param Psr\Http\Message\RequestInterface $response The http response to be decoded.
102106
* @param Psr\Http\Message\ResponseInterface $response
107+
* @param string $expectedClass
103108
* @return mixed|null
104109
*/
105110
public static function decodeHttpResponse(

src/Google/Service/Exception.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class Google_Service_Exception extends Google_Exception
3131
* @param Exception|null $previous
3232
* @param [{string, string}] errors List of errors returned in an HTTP
3333
* response. Defaults to [].
34-
* @param array|null $retryMap Map of errors with retry counts.
3534
*/
3635
public function __construct(
3736
$message,

0 commit comments

Comments
 (0)
X Tutup