Skip to content

Commit

Permalink
Merge pull request #12 from bow-swift/readme_2
Browse files Browse the repository at this point in the history
Readme
  • Loading branch information
miguelangel-dev authored Dec 11, 2019
2 parents eba58db + 017a3c9 commit e945e33
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 12 deletions.
52 changes: 48 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
<a href="https://www.apple.com/macos/catalina/">
<img src="https://img.shields.io/badge/macOS-10.15%2B-blue" alt="macOS 10.15+">
</a>

</p>

&nbsp;

This project provides an extension for Xcode to integrate some nef features directly in the IDE. Using the core of `nef`, you can [export snippets](https://github.com/bow-swift/nef#-exporting-carbon-code-snippets) from your code selection directly in Xcode.

### Features

πŸ’‘ Exports a [__code selection__](#-export-code-selection-to-image) to images for given Xcode Playgrounds.

πŸ’‘ Generates [__Markdown__](#-generates-markdown-file-from-playground) files from Xcode Playground.

πŸ’‘ Builds a [__Playground Book__](#-create-a-playground-book-from-your-swift-package) with external dependencies defined in a Swift Package.

&nbsp;

## πŸ“₯ Installation
Expand All @@ -37,16 +44,53 @@ To complete the installation, you should enable `nef` extension from `System Pre
<img src="assets/nef-plugin-extensions.png" alt="nef: enable Xcode extension" width="90%"/>
</p>

## 🌁 Export code selection to snippet
## Usage
### 🌁 Export code selection to image

In Xcode you can find the nef plugin options in `Editor`.

If you want to export your current code selection into a snippet, you only need to select the action `Editor > nef > Export code snippet`
If you want to export your current code selection into a snippet, you only need to select the action `Editor > nef > Code selection β†’ Image`

<p align="center">
<img src="assets/nef-plugin-action-export.png" alt="nef: action for exporting code selection to snippet" width="90%"/>
<img src="assets/nef-plugin-action-snippet.png" alt="nef: action for exporting code selection to snippet" width="50%"/>
</p>
<p align="center">
<img src="assets/arrow-down.png" alt="nef: action for exporting code selection to snippet" width="8%"/>
</p>
<p align="center">
<img src="assets/nef-plugin-action-snippet.png" alt="nef: action for exporting code selection to snippet" width="55%"/>
</p>

#### πŸ”§ Preferences

You can customize the output image using the preferences action `Editor > nef > Preferences`

<p align="center">
<img src="assets/nef-xcode-preferences.png" alt="nef: preferences Xcode extension" width="80%"/>
</p>

&nbsp;

### πŸ“ƒ Generates markdown file from Playground

Xcode Playgrounds let you write comments in markdown format using the symbols //: for single line comments, or /*: */ for multiline comments. Markup for playgrounds includes page level formatting for headings and other elements, formatting spans of characters, showing inline images, and several other features. You can read more in the [Markup Formatting Reference](https://developer.apple.com/library/archive/documentation/Xcode/Reference/xcode_markup_formatting_ref/index.html).

You can create a markdown file from playground page with the nef action `Editor > nef > Playground β†’ Markdown`

&nbsp;

### πŸ“² Create a Playground Book from your Swift package

You can create a Playground compatible with you iPad from a Swift package. You only need to open the swift package in Xcode,
and select the action `Editor > nef > Swift Package β†’ Playground Book`

It will ask you where to save the Playground Book, and it will start to build it.

<p align="center">
<img src="assets/nef-plugin-playgroundbook.png" alt="nef: action for making a Playground Book" width="90%"/>
</p>

> This feature needs to use SwiftPM tool. Consequently, it will need to disable the sandbox thus it is not allowed in the App Store; but if you want to enjoy this feature, you only need to install the `.dmg` you'll find in the [releases](https://github.com/bow-swift/nef-plugin/releases) section.
&nbsp;

Expand Down
2 changes: 1 addition & 1 deletion Support Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"copyright" = "Copyright Β© 2019 The nef authors";
"github" = "Read more about nef on GitHub";
"install_preferences" = "Open 'System Preferences'";
"install_extensions" = "Select 'Extension'";
"install_extensions" = "Select 'Extensions'";
"nef_extension" = "Xcode Source Editor";

// MARK: - Preferences
Expand Down
Binary file added assets/arrow-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/nef-plugin-action-export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/nef-plugin-action-snippet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/nef-plugin-extensions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/nef-plugin-playgroundbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/nef-xcode-preferences.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/nef-xcode-shortcuts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions nef-plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 107;
CURRENT_PROJECT_VERSION = 108;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.fortysevendeg.nef;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)App";
Expand All @@ -660,7 +660,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 107;
CURRENT_PROJECT_VERSION = 108;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.fortysevendeg.nef-plugin";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -736,7 +736,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 107;
CURRENT_PROJECT_VERSION = 108;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.fortysevendeg.nef;
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)App";
Expand All @@ -750,7 +750,7 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 107;
CURRENT_PROJECT_VERSION = 108;
MARKETING_VERSION = 2.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.fortysevendeg.nef-plugin";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
2 changes: 1 addition & 1 deletion nef-plugin/Support Files/Info-appstore.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<key>XCSourceEditorCommandIdentifier</key>
<string>markdownPage</string>
<key>XCSourceEditorCommandName</key>
<string>Plaground β†’ Markdown</string>
<string>Playground β†’ Markdown</string>
</dict>
</array>
<key>XCSourceEditorExtensionPrincipalClass</key>
Expand Down
4 changes: 2 additions & 2 deletions nef-plugin/Support Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@
<key>XCSourceEditorCommandIdentifier</key>
<string>markdownPage</string>
<key>XCSourceEditorCommandName</key>
<string>Plaground β†’ Markdown</string>
<string>Playground β†’ Markdown</string>
</dict>
<dict>
<key>XCSourceEditorCommandClassName</key>
<string>$(PRODUCT_MODULE_NAME).SourceEditorCommand</string>
<key>XCSourceEditorCommandIdentifier</key>
<string>playgroundBook</string>
<key>XCSourceEditorCommandName</key>
<string>Package β†’ Playground Book (iPad)</string>
<string>Swift Package β†’ Playground Book (iPad)</string>
</dict>
</array>
<key>XCSourceEditorExtensionPrincipalClass</key>
Expand Down
23 changes: 23 additions & 0 deletions nef/PlaygroundBook/PlaygroundBookView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ struct PlaygroundBookView: View {
static let nef = Image("nef-favicon")
}
}


// MARK: - previews
#if DEBUG
import nef
import BowEffects

struct PlaygroundBookView_Previews: PreviewProvider {
static let console = PlaygroundBookConsole()

static var previews: some View {
console.historical = "βœ“ It is a preview 1\nβœ“ It is a preview 2"
console.task = "Preview"
console.details = "Preview details"
console.totalSteps = 5
console.currentStep = 2
console.duration = .seconds(15)
console.status = .running

return PlaygroundBookView(console: console).frame(width: 800, height: 200, alignment: .center)
}
}
#endif

0 comments on commit e945e33

Please sign in to comment.