Skip to content

Commit

Permalink
Merge branch 'main' into swiftui
Browse files Browse the repository at this point in the history
  • Loading branch information
nighthawk committed Jun 4, 2022
2 parents fa795de + bcd1679 commit 0eacc0f
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build and Test

on:
workflow_dispatch: {}
pull_request:
branches: [ main ]
paths:
- 'Sources/**'
- '!Sources/Runestone/Documentation.docc/**'
- 'Tests/**'

jobs:
build:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/build_example_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Example Project

on:
workflow_dispatch: {}
pull_request:
branches: [ main ]
paths:
- 'Example/**'

jobs:
build:
name: Build example project for iPhone 13
runs-on: macOS-11
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
run: |
xcodebuild build -project Example/Example.xcodeproj -scheme Example -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13'
1 change: 1 addition & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SwiftLint

on:
workflow_dispatch: {}
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
Expand Down
5 changes: 5 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1
builder:
configs:
- platform: ios
documentation_targets: [Runestone]
7 changes: 7 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ let package = Package(
.testTarget(name: "RunestoneTests", dependencies: ["Runestone", "TestTreeSitterLanguages"])
]
)

#if swift(>=5.6)
// Add the documentation compiler plugin if possible
package.dependencies.append(
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
)
#endif
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

Runestone uses GitHub's [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) to parse code to a syntax tree which is used for features that require an understanding of the code in the editor, for example syntax highlighting.

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsimonbs%2FRunestone%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/simonbs/Runestone)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsimonbs%2FRunestone%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/simonbs/Runestone)
[![Build and Test](https://github.com/simonbs/Runestone/actions/workflows/build_and_test.yml/badge.svg)](https://github.com/simonbs/Runestone/actions/workflows/build_and_test.yml)
[![SwiftLint](https://github.com/simonbs/Runestone/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/simonbs/Runestone/actions/workflows/swiftlint.yml)
[![](https://img.shields.io/badge/[email protected]?style=flat)]([https://swiftpackageindex.com/simonbs/Runestone](https://twitter.com/simonbs))

## ✨ Features

- Syntax highlighting.
Expand Down
8 changes: 4 additions & 4 deletions Sources/Runestone/TextView/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import UIKit
///
/// The type does not subclass `UITextView` but its interface is kept close to `UITextView`.
///
/// When initially configuring the `TextView` with a theme, a language and the text to be shown, it is recommended the use the <doc:setState(_:addUndoAction:)> function.
/// The function takes an instance of <doc:TextViewState> as input which can be created on a background queue to avoid blocking the main queue while doing the initial parse of a text.
open class TextView: UIScrollView {
/// When initially configuring the `TextView` with a theme, a language and the text to be shown, it is recommended to use the ``setState(_:addUndoAction:)`` function.
/// The function takes an instance of ``TextViewState`` as input which can be created on a background queue to avoid blocking the main queue while doing the initial parse of a text.
open final class TextView: UIScrollView {
/// Delegate to receive callbacks for events triggered by the editor.
public weak var editorDelegate: TextViewDelegate?
/// Whether the text view is in a state where the contents can be edited.
Expand Down Expand Up @@ -531,7 +531,7 @@ open class TextView: UIScrollView {
///
/// The value only affects new line breaks inserted in the text view and changing this value does not change the line endings of the text in the text view. Defaults to Unix (LF).
///
/// The TextView will only update the line endings when text is modified through an external event, such as when the user typing on the keyboard, when the user is replacing selected text, and when pasting text into the text view. In all other cases, you should make sure that the text provided to the text view uses the desired line endings. This includes when calling <doc:TextView/setState(_:addUndoAction:)> and <doc:TextView/replaceText(in:)>.
/// The TextView will only update the line endings when text is modified through an external event, such as when the user typing on the keyboard, when the user is replacing selected text, and when pasting text into the text view. In all other cases, you should make sure that the text provided to the text view uses the desired line endings. This includes when calling ``TextView/setState(_:addUndoAction:)`` and ``TextView/replaceText(in:)``.
public var lineEndings: LineEnding {
get {
return textInputView.lineEndings
Expand Down
6 changes: 3 additions & 3 deletions Sources/Runestone/TextView/TextViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public protocol TextViewDelegate: AnyObject {
/// Tells the delegate when the text selection changes in the text view.
/// - Parameter textView: The text view whose selection changed.
///
/// You can use <doc:TextView/selectedRange> of the text view to get the new selection.
/// You can use ``TextView/selectedRange`` of the text view to get the new selection.
func textViewDidChangeSelection(_ textView: TextView)
/// Asks the delegate whether to replace the specified text in the text view.
/// - Parameters:
Expand Down Expand Up @@ -79,12 +79,12 @@ public protocol TextViewDelegate: AnyObject {
/// Tells the delegate that the text view looped to the last highlighted range.
/// - Parameter textView: The text view that looped to the last highlighted range.
///
/// The text view will loop to the last highlighted range in response to calling <doc:TextView/selectPreviousHighlightedRange()> while the first highlighted range is selected.
/// The text view will loop to the last highlighted range in response to calling ``TextView/selectPreviousHighlightedRange()`` while the first highlighted range is selected.
func textViewDidLoopToLastHighlightedRange(_ textView: TextView)
/// Tells the delegate that the text view looped to the first highlighted range.
/// - Parameter textView: The text view that looped to the first highlighted range.
///
/// The text view will loop to the first highlighted range in response to calling <doc:TextView/selectNextHighlightedRange()> while the last highlighted range is selected.
/// The text view will loop to the first highlighted range in response to calling ``TextView/selectNextHighlightedRange()`` while the last highlighted range is selected.
func textViewDidLoopToFirstHighlightedRange(_ textView: TextView)
/// Asks the delegate if the text in the highlighted range can be replaced.
/// - Parameters:
Expand Down
8 changes: 4 additions & 4 deletions Sources/Runestone/TextView/TextViewState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// Encapsulates the bare informations needed to do syntax highlighting in a text view.
///
/// It is recommended to create an instance of `TextViewState` on a background queue and pass it to a <doc:TextView> instead of setting the text, theme and language on the text view separately.
/// It is recommended to create an instance of `TextViewState` on a background queue and pass it to a ``TextView`` instead of setting the text, theme and language on the text view separately.
public final class TextViewState {
let stringView: StringView
let theme: Theme
Expand All @@ -21,7 +21,7 @@ public final class TextViewState {
/// The value is `nil` if the line ending cannot be detected.
public private(set) var detectedLineEndings: LineEnding?

/// Creates state that can be passed to an instance of <doc:TextView>.
/// Creates state that can be passed to an instance of ``TextView``.
/// - Parameters:
/// - text: The text to display in the text view.
/// - theme: The theme to use when syntax highlighting the text.
Expand All @@ -39,9 +39,9 @@ public final class TextViewState {
prepare(with: text)
}

/// Creates state that can be passed to an instance of <doc:TextView>.
/// Creates state that can be passed to an instance of ``TextView``.
///
/// The created theme will use an instance of <doc:PlainTextLanguageMode>.
/// The created theme will use an instance of ``PlainTextLanguageMode``.
/// - Parameters:
/// - text: The text to display in the text view.
/// - theme: The theme to use when syntax highlighting the text.
Expand Down

0 comments on commit 0eacc0f

Please sign in to comment.