From fbbd3d30066c6ac1d70ab13c122605fa51b47035 Mon Sep 17 00:00:00 2001 From: pgautier404 Date: Wed, 10 Jan 2024 16:39:45 -0800 Subject: [PATCH] chore: api snippet formatting (#92) * chore: trying to find an agreeable code format dart format and the API snippet parser haver incompatible requirements and I'm trying to satisfy both * chore: more trickery to get function defs spread across 2 lines * chore: using find to exclude doc examples The dart format utility keeps munging my api examples file such that it iss incompatible with the API snippet parser, so am using find to gather dart files to format and excluding the snippets explicitly. * fix: add in dart file in root of lib * fix: fixing find command format * fix: remove unneeded arg --- .github/workflows/on-pull-request.yml | 2 +- example/doc_example_apis/doc_example_apis.dart | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index 6e1d731..3a4a522 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -22,7 +22,7 @@ jobs: # Uncomment this step to verify the use of 'dart format' on each commit. - name: Verify formatting - run: dart format --output=none --set-exit-if-changed . + run: find lib/momento.dart lib/src example test -name "*.dart" -not -name doc_example_apis.dart -exec dart format --output=none --set-exit-if-changed {} \; # Consider passing '--fatal-infos' for slightly stricter analysis. - name: Analyze project source diff --git a/example/doc_example_apis/doc_example_apis.dart b/example/doc_example_apis/doc_example_apis.dart index aa46193..680e674 100644 --- a/example/doc_example_apis/doc_example_apis.dart +++ b/example/doc_example_apis/doc_example_apis.dart @@ -14,8 +14,7 @@ Future example_API_InstantiateCacheClient() async { } } -Future example_API_CreateCache( - CacheClient cacheClient, String cacheName) async { +Future example_API_CreateCache(CacheClient cacheClient, String cacheName) async { final result = await cacheClient.createCache(cacheName); switch (result) { case CreateCacheAlreadyExists(): @@ -37,8 +36,7 @@ Future example_API_ListCaches(CacheClient cacheClient) async { } } -Future example_API_DeleteCache( - CacheClient cacheClient, String cacheName) async { +Future example_API_DeleteCache(CacheClient cacheClient, String cacheName) async { final result = await cacheClient.deleteCache(cacheName); switch (result) { case DeleteCacheError(): @@ -49,8 +47,7 @@ Future example_API_DeleteCache( } } -Future example_API_Set( - CacheClient cacheClient, String cacheName, Value key, Value value) async { +Future example_API_Set(CacheClient cacheClient, String cacheName, Value key, Value value) async { final result = await cacheClient.set(cacheName, key, value); switch (result) { case SetError(): @@ -61,8 +58,7 @@ Future example_API_Set( } } -Future example_API_Get( - CacheClient cacheClient, String cacheName, Value key) async { +Future example_API_Get(CacheClient cacheClient, String cacheName, Value key) async { final result = await cacheClient.get(cacheName, key); switch (result) { case GetMiss(): @@ -74,8 +70,7 @@ Future example_API_Get( } } -Future example_API_Delete( - CacheClient cacheClient, String cacheName, Value key) async { +Future example_API_Delete(CacheClient cacheClient, String cacheName, Value key) async { final result = await cacheClient.delete(cacheName, key); switch (result) { case DeleteError():