From bcb328e6898d33c8372377a066a782732d532090 Mon Sep 17 00:00:00 2001 From: Marco Eidinger Date: Sun, 8 Jan 2023 15:11:46 -0800 Subject: [PATCH] 1.4.0 --- CHANGELOG.md | 23 ++++ SwiftPlantUMLApp.xcodeproj/project.pbxproj | 54 +++++---- .../xcshareddata/swiftpm/Package.resolved | 114 +++++++++--------- SwiftPlantUMLApp/SettingsView.swift | 30 ++++- SwiftPlantUMLApp/Shared/SettingsModel.swift | 16 ++- SwiftPlantUMLApp/Shared/Utils.swift | 4 +- XPCService/XPCService.swift | 50 +++++--- 7 files changed, 192 insertions(+), 99 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f174c..0686d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +# [1.4.0](https://github.com/MarcoEidinger/SwiftPlantUML-Xcode-Extension/releases/tag/1.4.0) + +## Features + +- [X] Able to merge extensions into main type. + + merged_extensions + +- [X] Able to choose a theme + + theme_sketchy_outline + +## Improvements + +- [X] Show Nested Types + + nestedTypes +- [X] Several Bug Fixes + +## Internal Dependencies + +uses [SwiftPlantUML@0.7.0](https://github.com/MarcoEidinger/SwiftPlantUML/releases/tag/0.7.0) + # [1.3.0](https://github.com/MarcoEidinger/SwiftPlantUML-Xcode-Extension/releases/tag/1.3.0) ## Features diff --git a/SwiftPlantUMLApp.xcodeproj/project.pbxproj b/SwiftPlantUMLApp.xcodeproj/project.pbxproj index 69af63f..83b5c24 100644 --- a/SwiftPlantUMLApp.xcodeproj/project.pbxproj +++ b/SwiftPlantUMLApp.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 1919C9C8296B48EA00804361 /* SwiftPlantUMLFramework in Frameworks */ = {isa = PBXBuildFile; productRef = 1919C9C7296B48EA00804361 /* SwiftPlantUMLFramework */; }; + 1919C9CA296B48FC00804361 /* SwiftPlantUMLFramework in Frameworks */ = {isa = PBXBuildFile; productRef = 1919C9C9296B48FC00804361 /* SwiftPlantUMLFramework */; }; 8A1EFEF42735DEC000BD6F69 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A1EFEF32735DEC000BD6F69 /* Utils.swift */; }; 8A30356F279BA55700042D19 /* PreferencesCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A30356E279BA55700042D19 /* PreferencesCommand.swift */; }; 8A319170261911B900540446 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A31916F261911B900540446 /* AppDelegate.swift */; }; @@ -22,7 +24,6 @@ 8A73D8EA25CAE9AA008DDEA3 /* GenDiagramInBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A73D8E925CAE9AA008DDEA3 /* GenDiagramInBrowser.swift */; }; 8A73D8EF25CAE9AA008DDEA3 /* SourceEditorExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 8A73D8E025CAE9AA008DDEA3 /* SourceEditorExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 8A73D90525CAE9DD008DDEA3 /* XPCService.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 8A73D8FA25CAE9DD008DDEA3 /* XPCService.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; - 8A73D90F25CAEA3A008DDEA3 /* SwiftPlantUMLFramework in Frameworks */ = {isa = PBXBuildFile; productRef = 8A73D90E25CAEA3A008DDEA3 /* SwiftPlantUMLFramework */; }; 8A73D91425CAEA78008DDEA3 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A73D91325CAEA78008DDEA3 /* main.swift */; }; 8A73D91925CAEA8F008DDEA3 /* XPCServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A73D91825CAEA8F008DDEA3 /* XPCServiceProtocol.swift */; }; 8A73D91E25CAEA9E008DDEA3 /* XPCService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A73D91D25CAEA9E008DDEA3 /* XPCService.swift */; }; @@ -140,6 +141,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1919C9C8296B48EA00804361 /* SwiftPlantUMLFramework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -156,7 +158,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8A73D90F25CAEA3A008DDEA3 /* SwiftPlantUMLFramework in Frameworks */, + 1919C9CA296B48FC00804361 /* SwiftPlantUMLFramework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -272,6 +274,9 @@ 8A73D90425CAE9DD008DDEA3 /* PBXTargetDependency */, ); name = SwiftPlantUMLApp; + packageProductDependencies = ( + 1919C9C7296B48EA00804361 /* SwiftPlantUMLFramework */, + ); productName = SwiftPlantUMLApp; productReference = 8A73D8C825CAE974008DDEA3 /* SwiftPlantUMLApp.app */; productType = "com.apple.product-type.application"; @@ -292,6 +297,8 @@ 8A73D92625CAEB2B008DDEA3 /* PBXTargetDependency */, ); name = SourceEditorExtension; + packageProductDependencies = ( + ); productName = SourceEditorExtension; productReference = 8A73D8E025CAE9AA008DDEA3 /* SourceEditorExtension.appex */; productType = "com.apple.product-type.xcode-extension"; @@ -310,7 +317,7 @@ ); name = XPCService; packageProductDependencies = ( - 8A73D90E25CAEA3A008DDEA3 /* SwiftPlantUMLFramework */, + 1919C9C9296B48FC00804361 /* SwiftPlantUMLFramework */, ); productName = XPCService; productReference = 8A73D8FA25CAE9DD008DDEA3 /* XPCService.xpc */; @@ -347,7 +354,7 @@ ); mainGroup = 8A73D8BF25CAE974008DDEA3; packageReferences = ( - 8A73D90D25CAEA3A008DDEA3 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */, + 1919C9C6296B48EA00804361 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */, ); productRefGroup = 8A73D8C925CAE974008DDEA3 /* Products */; projectDirPath = ""; @@ -582,7 +589,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"SwiftPlantUMLApp/Preview Content\""; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; @@ -593,7 +600,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUML; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -611,7 +618,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"SwiftPlantUMLApp/Preview Content\""; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; @@ -622,7 +629,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUML; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -637,7 +644,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = SourceEditorExtension/Info.plist; @@ -646,7 +653,7 @@ "@executable_path/../Frameworks", "@executable_path/../../../../Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUMLSourceEditorExtension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -662,7 +669,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = SourceEditorExtension/Info.plist; @@ -671,7 +678,7 @@ "@executable_path/../Frameworks", "@executable_path/../../../../Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUMLSourceEditorExtension; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -688,7 +695,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = XPCService/Info.plist; @@ -697,7 +704,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUMLXPCService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -715,7 +722,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 6V66CC3AN6; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = XPCService/Info.plist; @@ -724,7 +731,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.4.0; PRODUCT_BUNDLE_IDENTIFIER = us.eidinger.SwiftPlantUMLXPCService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -775,20 +782,25 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 8A73D90D25CAEA3A008DDEA3 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */ = { + 1919C9C6296B48EA00804361 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/MarcoEidinger/SwiftPlantUML"; + repositoryURL = "https://github.com/MarcoEidinger/SwiftPlantUML.git"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 0.6.0; + minimumVersion = 0.7.0; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - 8A73D90E25CAEA3A008DDEA3 /* SwiftPlantUMLFramework */ = { + 1919C9C7296B48EA00804361 /* SwiftPlantUMLFramework */ = { + isa = XCSwiftPackageProductDependency; + package = 1919C9C6296B48EA00804361 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */; + productName = SwiftPlantUMLFramework; + }; + 1919C9C9296B48FC00804361 /* SwiftPlantUMLFramework */ = { isa = XCSwiftPackageProductDependency; - package = 8A73D90D25CAEA3A008DDEA3 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */; + package = 1919C9C6296B48EA00804361 /* XCRemoteSwiftPackageReference "SwiftPlantUML" */; productName = SwiftPlantUMLFramework; }; /* End XCSwiftPackageProductDependency section */ diff --git a/SwiftPlantUMLApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/SwiftPlantUMLApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index aba3a11..22c7455 100644 --- a/SwiftPlantUMLApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/SwiftPlantUMLApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,61 +1,59 @@ { - "object": { - "pins": [ - { - "package": "SourceKitten", - "repositoryURL": "https://github.com/jpsim/SourceKitten", - "state": { - "branch": null, - "revision": "558628392eb31d37cb251cfe626c53eafd330df6", - "version": "0.31.1" - } - }, - { - "package": "swift-argument-parser", - "repositoryURL": "https://github.com/apple/swift-argument-parser.git", - "state": { - "branch": null, - "revision": "d2930e8fcf9c33162b9fcc1d522bc975e2d4179b", - "version": "1.0.1" - } - }, - { - "package": "SwiftPlantUML", - "repositoryURL": "https://github.com/MarcoEidinger/SwiftPlantUML", - "state": { - "branch": null, - "revision": "0ca974652eb597a3fe2811e5146fdb9626fb390b", - "version": "0.6.0" - } - }, - { - "package": "SwiftyBeaver", - "repositoryURL": "https://github.com/SwiftyBeaver/SwiftyBeaver.git", - "state": { - "branch": null, - "revision": "2c039501d6eeb4d4cd4aec4a8d884ad28862e044", - "version": "1.9.5" - } - }, - { - "package": "SWXMLHash", - "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", - "state": { - "branch": null, - "revision": "a4931e5c3bafbedeb1601d3bb76bbe835c6d475a", - "version": "5.0.1" - } - }, - { - "package": "Yams", - "repositoryURL": "https://github.com/jpsim/Yams.git", - "state": { - "branch": null, - "revision": "9003d51672e516cc59297b7e96bff1dfdedcb4ea", - "version": "4.0.4" - } + "pins" : [ + { + "identity" : "sourcekitten", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jpsim/SourceKitten", + "state" : { + "revision" : "558628392eb31d37cb251cfe626c53eafd330df6", + "version" : "0.31.1" } - ] - }, - "version": 1 + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser.git", + "state" : { + "revision" : "d2930e8fcf9c33162b9fcc1d522bc975e2d4179b", + "version" : "1.0.1" + } + }, + { + "identity" : "swiftplantuml", + "kind" : "remoteSourceControl", + "location" : "https://github.com/MarcoEidinger/SwiftPlantUML.git", + "state" : { + "revision" : "6135cf9e9dd666be2f5cf646cc393a7e157c3e70", + "version" : "0.7.0" + } + }, + { + "identity" : "swiftybeaver", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SwiftyBeaver/SwiftyBeaver.git", + "state" : { + "revision" : "2c039501d6eeb4d4cd4aec4a8d884ad28862e044", + "version" : "1.9.5" + } + }, + { + "identity" : "swxmlhash", + "kind" : "remoteSourceControl", + "location" : "https://github.com/drmohundro/SWXMLHash.git", + "state" : { + "revision" : "a4931e5c3bafbedeb1601d3bb76bbe835c6d475a", + "version" : "5.0.1" + } + }, + { + "identity" : "yams", + "kind" : "remoteSourceControl", + "location" : "https://github.com/jpsim/Yams.git", + "state" : { + "revision" : "9003d51672e516cc59297b7e96bff1dfdedcb4ea", + "version" : "4.0.4" + } + } + ], + "version" : 2 } diff --git a/SwiftPlantUMLApp/SettingsView.swift b/SwiftPlantUMLApp/SettingsView.swift index 3357fed..260703e 100644 --- a/SwiftPlantUMLApp/SettingsView.swift +++ b/SwiftPlantUMLApp/SettingsView.swift @@ -1,5 +1,15 @@ import Foundation import SwiftUI +import SwiftPlantUMLFramework + +extension Theme { + public static var chooseable: [String] { + var values: [String] = [] + values.append("") + values.append(contentsOf: Theme.preferred.map { $0.rawValue }) + return values + } +} struct SettingsView: View { @EnvironmentObject private var mainState: ContentViewModel @@ -60,8 +70,26 @@ struct SettingsView: View { } if selectedConfigurationScope == .others { VStack(alignment: .leading) { + HStack { + Spacer(minLength: 19) + Picker("Theme", selection: $mainState.settings.theme) { + ForEach(Theme.chooseable, id: \.self) { + Text($0) + } + } + Spacer(minLength: 150) + } + HStack { + Spacer(minLength: 19) + Picker("Show extensions", selection: $mainState.settings.showExtensionsValue) { + Text(ExtensionVisualization.all.rawValue).tag(ExtensionVisualization.all.rawValue) + Text(ExtensionVisualization.merged.rawValue).tag(ExtensionVisualization.merged.rawValue) + Text(ExtensionVisualization.none.rawValue).tag(ExtensionVisualization.none.rawValue) + } + Spacer(minLength: 150) + } Toggle("Show generics", isOn: $mainState.settings.showGenerics) - Toggle("Show extensions", isOn: $mainState.settings.showExtensions) + Toggle("Show nested types", isOn: $mainState.settings.showNestedTypes) } } } diff --git a/SwiftPlantUMLApp/Shared/SettingsModel.swift b/SwiftPlantUMLApp/Shared/SettingsModel.swift index 5911aa5..93a77e2 100644 --- a/SwiftPlantUMLApp/Shared/SettingsModel.swift +++ b/SwiftPlantUMLApp/Shared/SettingsModel.swift @@ -1,11 +1,17 @@ import Foundation struct SettingsModel { + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.theme.key, defaultValue: "") + var theme: String + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showGenerics.key, defaultValue: true) var showGenerics: Bool - - @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showExtensions.key, defaultValue: true) - var showExtensions: Bool + + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showNestedTypes.key, defaultValue: true) + var showNestedTypes: Bool + + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showExtensionsValue.key, defaultValue: "all") + var showExtensionsValue: String @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showEmptyMembers.key, defaultValue: true) var showEmptyMembers: Bool @@ -35,8 +41,10 @@ struct SettingsModel { var showElementsWithAccessLevelPrivate: Bool mutating func resetDefaults() { + theme = "" showGenerics = true - showExtensions = true + showNestedTypes = true + showExtensionsValue = "all" showEmptyMembers = true showMembersWithAccessLevelOpen = true showMembersWithAccessLevelPublic = true diff --git a/SwiftPlantUMLApp/Shared/Utils.swift b/SwiftPlantUMLApp/Shared/Utils.swift index e0e9c47..b004139 100644 --- a/SwiftPlantUMLApp/Shared/Utils.swift +++ b/SwiftPlantUMLApp/Shared/Utils.swift @@ -39,8 +39,10 @@ public extension UserDefaults { public enum UserDefaultsKeys { public enum SettingsKeys: String, CaseIterable { + case theme case showGenerics - case showExtensions + case showNestedTypes + case showExtensionsValue case showEmptyMembers case showMembersWithAccessLevelOpen case showMembersWithAccessLevelPublic diff --git a/XPCService/XPCService.swift b/XPCService/XPCService.swift index f6bfedc..553b572 100644 --- a/XPCService/XPCService.swift +++ b/XPCService/XPCService.swift @@ -2,11 +2,17 @@ import Foundation import SwiftPlantUMLFramework @objc class XPCService: NSObject, XPCServiceProtocol { + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.theme.key, defaultValue: "") + var theme: String + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showGenerics.key, defaultValue: true) var showGenerics: Bool - - @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showExtensions.key, defaultValue: true) - var showExtensions: Bool + + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showNestedTypes.key, defaultValue: true) + var showNestedTypes: Bool + + @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showExtensionsValue.key, defaultValue: ExtensionVisualization.default.rawValue) + var showExtensionsValue: String @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showEmptyMembers.key, defaultValue: true) var showEmptyMembers: Bool @@ -34,14 +40,12 @@ import SwiftPlantUMLFramework @UserDefaultsWrapper(UserDefaultsKeys.SettingsKeys.showElementsWithAccessLevelPrivate.key, defaultValue: true) var showElementsWithAccessLevelPrivate: Bool - - func generateDiagram(from content: String, completionHandler: @escaping (() -> Void)) { - let config = Configuration(elements: ElementOptions(havingAccessLevel: showElementsWithAccessLevel(), showMembersWithAccessLevel: showMembersWithAccessLevel(), showGenerics: showGenerics, showExtensions: showExtensions, showMemberAccessLevelAttribute: true, exclude: nil), hideShowCommands: hideShowCommands()) - ClassDiagramGenerator().generate(from: content, with: config) - completionHandler() + + var extensionVisualization: ExtensionVisualization { + ExtensionVisualization(rawValue: showExtensionsValue) ?? .all } - - private func showElementsWithAccessLevel() -> [AccessLevel] { + + var showElementsWithAccessLevel: [AccessLevel] { var showElementsWithAccessLevel: [AccessLevel] = [] if showElementsWithAccessLevelOpen { showElementsWithAccessLevel.append(.open) @@ -57,8 +61,8 @@ import SwiftPlantUMLFramework } return showElementsWithAccessLevel } - - private func showMembersWithAccessLevel() -> [AccessLevel] { + + var showMembersWithAccessLevel: [AccessLevel] { var showMembersWithAccessLevel: [AccessLevel] = [] if showMembersWithAccessLevelOpen { showMembersWithAccessLevel.append(.open) @@ -74,12 +78,30 @@ import SwiftPlantUMLFramework } return showMembersWithAccessLevel } - - private func hideShowCommands() -> [String] { + + var hideShowCommands: [String] { var hideShowCommands = [String]() if !showEmptyMembers { hideShowCommands.append("hide empty members") } return hideShowCommands } + + var selectedTheme: Theme? { + var selTheme: Theme? = nil + if !theme.isEmpty { + selTheme = Theme.__directive__(theme) + } + return selTheme + } + + func generateDiagram(from content: String, completionHandler: @escaping (() -> Void)) { + let showNestedTypes = showNestedTypes + let extensionVisualization = extensionVisualization + let selectedTheme = selectedTheme + + let config = Configuration(elements: ElementOptions(havingAccessLevel: showElementsWithAccessLevel, showMembersWithAccessLevel: showMembersWithAccessLevel, showNestedTypes: showNestedTypes, showGenerics: showGenerics, showExtensions: extensionVisualization, showMemberAccessLevelAttribute: true, exclude: nil), hideShowCommands: hideShowCommands, theme: selectedTheme) + ClassDiagramGenerator().generate(from: content, with: config) + completionHandler() + } }