Skip to content

Commit 49338d9

Browse files
committed
Added a new top level entry point: hooks.dart
improve dartdocs and IDE usability when writing hooks
1 parent 8c33a5b commit 49338d9

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 6.2.1
22
- Consolidated utils from src/util.dart into src/common/utils/utils.dart
3+
- Added a new top level entry point `hooks.dart` to improve dartdocs and IDE usability when writing hooks
34

45
## 6.2.0
56
- Added Checks API https://github.com/SpinlockLabs/github.dart/pull/182

lib/hooks.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// This entrypoint is here so that dartdoc will generate documentation for
2+
/// files under lib/src/server. This is only necessary because conditional
3+
/// import/export isn't well supported in the Dart ecosystem.
4+
///
5+
/// Add this import if you are in a non-web environment and writing something
6+
/// that uses github hooks. For more information, see github hooks documentation
7+
/// https://developer.github.com/v3/repos/hooks/
8+
/// `import 'pacakge:github/hooks.dart';`
9+
library hooks;
10+
11+
export 'src/server/xplat_server.dart';

lib/src/common/xplat_common.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
import 'package:github/src/common.dart';
22

3+
/// Looks for GitHub Authentication information from the current environment.
4+
///
5+
/// If in a browser context, it will look through query string parameters first
6+
/// and then sessionStorage.
7+
///
8+
/// If in a server, command line or Flutter context it will use the system environment variables.
9+
///
10+
/// In both contexts it delegates to [findAuthenticationInMap] to find the
11+
/// github token or username and password.
312
Authentication findAuthenticationFromEnvironment() =>
413
Authentication.anonymous();
514

15+
/// Checks the passed in map for keys in [COMMON_GITHUB_TOKEN_ENV_KEYS].
16+
/// The first one that exists is used as the github token to call [Authentication.withToken] with.
17+
/// If the above fails, the GITHUB_USERNAME and GITHUB_PASSWORD keys will be checked.
18+
/// If those keys both exist, then [Authentication.basic] will be used.
619
Authentication findAuthenticationInMap(Map map) {
720
for (final key in COMMON_GITHUB_TOKEN_ENV_KEYS) {
821
if (map.containsKey(key)) {

0 commit comments

Comments
 (0)