From ee57bf7bb544b105c5d91aaa2ef348d0f663a690 Mon Sep 17 00:00:00 2001 From: Adrian Secord Date: Thu, 21 Dec 2017 13:44:00 -0500 Subject: [PATCH] Add "related info" URLs to examples (#24) * Added related info URL. * Remove example related info links, we're not using them. --- example/Podfile.lock | 4 ++-- src/CBCCatalogExample.h | 3 +++ src/CBCNodeListViewController.m | 5 +++++ src/private/CBCRuntime.h | 3 +++ src/private/CBCRuntime.m | 8 ++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/example/Podfile.lock b/example/Podfile.lock index e3a52b1..93973d6 100644 --- a/example/Podfile.lock +++ b/example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - CatalogByConvention (2.2.0) + - CatalogByConvention (2.3.1) - CatalogExamples (1.0.0) - CatalogUnitTests (1.0.0): - Resistor @@ -22,7 +22,7 @@ EXTERNAL SOURCES: :path: components/Resistor SPEC CHECKSUMS: - CatalogByConvention: 5df5831e48b8083b18570dcb804f20fd1c90694f + CatalogByConvention: 1df2d770271921f668a99245c7c4c129e78941ee CatalogExamples: cafe3e4eae3abc948d96beb626657455c1dfb327 CatalogUnitTests: b7a746f12abb31a905654521ee926ea007ab7275 Resistor: 36a9ae98666be3b4f34d8133fad442fa87fdbce2 diff --git a/src/CBCCatalogExample.h b/src/CBCCatalogExample.h index 564c790..31deb60 100644 --- a/src/CBCCatalogExample.h +++ b/src/CBCCatalogExample.h @@ -53,4 +53,7 @@ /** Return a description of the example. */ - (nonnull NSString *)catalogDescription; +/** Return a link to related information or resources. */ +- (nonnull NSURL *)catalogRelatedInfo; + @end diff --git a/src/CBCNodeListViewController.m b/src/CBCNodeListViewController.m index 76f5afd..e7f5f84 100644 --- a/src/CBCNodeListViewController.m +++ b/src/CBCNodeListViewController.m @@ -85,6 +85,11 @@ - (NSString *)exampleDescription { return CBCDescriptionFromClass(_exampleClass); } +- (NSURL *)exampleRelatedInfo { + NSAssert(_exampleClass != nil, @"This node has no associated example."); + return CBCRelatedInfoFromClass(_exampleClass); +} + - (BOOL)isPrimaryDemo { return CBCCatalogIsPrimaryDemoFromClass(_exampleClass); } diff --git a/src/private/CBCRuntime.h b/src/private/CBCRuntime.h index d7ccdc6..aad0663 100644 --- a/src/private/CBCRuntime.h +++ b/src/private/CBCRuntime.h @@ -60,6 +60,9 @@ FOUNDATION_EXTERN UIViewController *CBCViewControllerFromClass(Class aClass); /** Create a description from the provided class. **/ FOUNDATION_EXTERN NSString *CBCDescriptionFromClass(Class aClass); +/** Create a link to related information from the provided class. **/ +FOUNDATION_EXTERN NSURL *CBCRelatedInfoFromClass(Class aClass); + #pragma mark Fix View Debugging /** diff --git a/src/private/CBCRuntime.m b/src/private/CBCRuntime.m index 1b2f513..738748a 100644 --- a/src/private/CBCRuntime.m +++ b/src/private/CBCRuntime.m @@ -138,6 +138,14 @@ BOOL CBCCatalogIsDebugLeaf(Class aClass) { return nil; } +NSURL *CBCRelatedInfoFromClass(Class aClass) { + if ([aClass respondsToSelector:@selector(catalogRelatedInfo)]) { + NSURL *catalogRelatedInfo = [aClass catalogRelatedInfo]; + return catalogRelatedInfo; + } + return nil; +} + #pragma mark Fix View Debugging void CBCFixViewDebuggingIfNeeded(void) {