Compare commits

...

9 Commits

Author SHA1 Message Date
Seyed Mojtaba Hosseini Zeidabadi
2314c2889b
Merge 2f2fd65370 into 8beb3b2d2d 2024-08-06 09:48:13 -06:00
Mizuo Nagayama
8beb3b2d2d
fix plural in ProjectSpec.md (#1487) 2024-08-06 05:35:27 +09:00
Seyed Mojtaba Hosseini Zeidabadi
2f2fd65370 docs: update the change log for renderMarkdown spec option 2022-11-22 13:18:03 +03:30
Seyed Mojtaba Hosseini Zeidabadi
9d64afa4bd add: mark down renderer spec option 2022-11-22 13:17:35 +03:30
Seyed Mojtaba Hosseini Zeidabadi
cafbf2dac3 add: delete markdown renderer function to remove it when it’s false 2022-11-22 13:16:01 +03:30
Seyed Mojtaba Hosseini Zeidabadi
f9db8c5449 better message for enabeling xcode markdown rendering 2022-11-09 18:58:44 +03:30
Seyed Mojtaba Hosseini Zeidabadi
db0db75e63 cleaned xcodesamplecode.plist file generation code 2022-11-09 18:19:49 +03:30
Seyed Mojtaba Hosseini Zeidabadi
25ea10f50c update changelog for the —render-markdowns command flag 2022-11-09 17:28:42 +03:30
Seyed Mojtaba Hosseini Zeidabadi
24f8ae15cf Add: markdown renderer command flag 2022-11-09 17:22:56 +03:30
5 changed files with 53 additions and 1 deletions

View File

@ -158,6 +158,8 @@
- Config setting presets can now also be loaded from the main bundle when bundling XcodeGenKit #1135 @SofteqDG
- Added ability to generate multiple projects in one XcodeGen launch #1270 @skofgar
- Use memoization during recursive SpecFiles creation. This provides a drastic performance boost with lots of recursive includes #1275 @ma-oli
- Added `--render-markdowns` command flag to generate the `.xcodesamplecode.plist` inside the project container and let Xcode render the markdown files with `md` extension.
- Added `renderMarkdown` spec option generate the `.xcodesamplecode.plist` inside the project container and let Xcode render the markdown files with `md` extension.
### Fixed

View File

@ -1039,7 +1039,7 @@ The different actions share some properties:
- [ ] **askForAppToLaunch**: **Bool** - `run` and `profile` actions can define the executable set to ask to launch. This defaults to false.
- [ ] **launchAutomaticallySubstyle**: **String** - `run` action can define the launch automatically substyle ('2' for extensions).
- [ ] **storeKitConfiguration**: **String** - `run` action can specify a storekit configuration. See [Options](#options).
- [ ] **macroExpansion**: **String** - `run` and `test` action can define the macro expansion from other target. This defaults to nil.
- [ ] **macroExpansion**: **String** - `run` and `test` actions can define the macro expansion from other target. This defaults to nil.
### Execution Action

View File

@ -16,6 +16,7 @@ public struct SpecOptions: Equatable {
public var carthageBuildPath: String?
public var carthageExecutablePath: String?
public var createIntermediateGroups: Bool
public var renderMarkdowns: Bool?
public var bundleIdPrefix: String?
public var settingPresets: SettingPresets
public var disabledValidations: [ValidationType]
@ -80,6 +81,7 @@ public struct SpecOptions: Equatable {
carthageBuildPath: String? = nil,
carthageExecutablePath: String? = nil,
createIntermediateGroups: Bool = createIntermediateGroupsDefault,
renderMarkdowns: Bool? = nil,
bundleIdPrefix: String? = nil,
settingPresets: SettingPresets = settingPresetsDefault,
developmentLanguage: String? = nil,
@ -106,6 +108,7 @@ public struct SpecOptions: Equatable {
self.carthageBuildPath = carthageBuildPath
self.carthageExecutablePath = carthageExecutablePath
self.createIntermediateGroups = createIntermediateGroups
self.renderMarkdowns = renderMarkdowns
self.bundleIdPrefix = bundleIdPrefix
self.settingPresets = settingPresets
self.developmentLanguage = developmentLanguage
@ -142,6 +145,7 @@ extension SpecOptions: JSONObjectConvertible {
bundleIdPrefix = jsonDictionary.json(atKeyPath: "bundleIdPrefix")
settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? SpecOptions.settingPresetsDefault
createIntermediateGroups = jsonDictionary.json(atKeyPath: "createIntermediateGroups") ?? SpecOptions.createIntermediateGroupsDefault
renderMarkdowns = jsonDictionary.json(atKeyPath: "renderMarkdowns")
developmentLanguage = jsonDictionary.json(atKeyPath: "developmentLanguage")
usesTabs = jsonDictionary.json(atKeyPath: "usesTabs")
xcodeVersion = jsonDictionary.json(atKeyPath: "xcodeVersion")

View File

@ -19,6 +19,9 @@ class GenerateCommand: ProjectCommand {
@Flag("--only-plists", description: "Generate only plist files")
var onlyPlists: Bool
@Flag("--render-markdowns", description: "Render markdown files with `.md` extension")
var renderMarkdowns: Bool
init(version: Version) {
super.init(version: version,
@ -119,6 +122,39 @@ class GenerateCommand: ProjectCommand {
} catch {
throw GenerationError.writingError(error)
}
switch project.options.renderMarkdowns {
case .some(true):
do {
try fileWriter.writeMarkdownRendererPlist()
success("Xcode markdown rendering enabled")
} catch {
throw GenerationError.writingError(error)
}
case .some(false):
do {
try fileWriter.deleteMarkdownRendererPlist()
success("Xcode markdown rendering disabled")
} catch {
info("Failed to disable Xcode markdown rendering: \(error.localizedDescription)")
}
case .none: break
// No need for change
}
// add markdown renderer if needed
/// - Note: this flag will override the spec option
if renderMarkdowns && project.options.renderMarkdowns != true {
do {
if project.options.renderMarkdowns == false {
info("Overriding markdown rendering option because of the given --render-markdowns flag")
}
try fileWriter.writeMarkdownRendererPlist()
success("Xcode markdown rendering enabled")
} catch {
throw GenerationError.writingError(error)
}
}
// write cache
if let cacheFile = cacheFile {

View File

@ -40,6 +40,16 @@ public class FileWriter {
}
}
}
public func writeMarkdownRendererPlist() throws {
let path = project.defaultProjectPath + ".xcodesamplecode.plist"
try writePlist([:], path: path.string)
}
public func deleteMarkdownRendererPlist() throws {
let path = project.defaultProjectPath + ".xcodesamplecode.plist"
try path.delete()
}
private func writePlist(_ plist: [String: Any], path: String) throws {
let path = project.basePath + path