Skip to content

Commit 6b412f6

Browse files
authored
Merge pull request #9 from lukepistrol/documentation/update-guides
[documentation]: Add `Update-Languages` Guide
2 parents abe2969 + 0695233 commit 6b412f6

File tree

14 files changed

+98
-32
lines changed

14 files changed

+98
-32
lines changed

CodeLanguages-Container/CodeLanguages-Container.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
5.13 KB
Binary file not shown.

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<a aria-label="Join the community on Discord" href="https://discord.gg/vChUXVf9Em" target="_blank">
1111
<img alt="" src="https://img.shields.io/badge/Join%20the%20community-black.svg?style=for-the-badge&logo=Discord">
1212
</a>
13+
<a aria-label="Read the Documentation" href="https://codeeditapp.github.io/CodeEditLanguages/documentation/codeeditlanguages" target="_blank">
14+
<img alt="" src="https://img.shields.io/badge/Documentation-black.svg?style=for-the-badge&logo=readthedocs&logoColor=blue">
15+
</a>
1316
</p>
1417

1518
A collection of `tree-sitter` languages for syntax highlighting.
@@ -22,10 +25,14 @@ A collection of `tree-sitter` languages for syntax highlighting.
2225

2326
## Overview
2427

25-
This package includes a binary framework `CodeLanguagesContainer.xcframework` which bundles all languages as a binary.
28+
This package includes a binary framework `CodeLanguagesContainer.xcframework` which bundles all `tree-sitter` languages in a single binary to greatly reduce SPM package resolution times.
2629

2730
The languages are then served as a `CodeLanguage`.
2831

32+
## SwiftTreeSitter
33+
34+
This package heavily depends on [SwiftTreeSitter](https://github.com/ChimeHQ/SwiftTreeSitter) by [Matt Massicotte](https://twitter.com/mattie).
35+
2936
## Documentation
3037

3138
The documentation including a guide on how to add support for new languages can be found **[here](https://codeeditapp.github.io/CodeEditLanguages/documentation/codeeditlanguages)**!

Sources/CodeEditLanguages/Documentation.docc/Add-Languages.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ This article is a writedown on how to add support for more languages to ``CodeLa
66

77
First of all have a look at the corresponding [GitHub Issue](https://github.com/CodeEditApp/CodeEditTextView/issues/15) to see which languages still need implementation.
88

9+
> Note: If you want to update existing languages see <doc:Update-Languages> instead.
10+
911
## Add SPM support
1012

1113
If you find one you want to add, fork and clone the linked repo and create a new branch `feature/spm`.
1214

13-
> In the following code samples replace `{LANG}` or `{lang}` with the language you add (e.g.: `Swift` or `CPP` and `swift` or `cpp` respectively)
15+
> Tip: In the following code samples replace `{LANG}` or `{lang}` with the language you add (e.g.: `Swift` or `CPP` and `swift` or `cpp` respectively)
1416
1517
### .gitignore
1618

@@ -20,7 +22,7 @@ Edit the `.gitignore` file to exclude the `.build/` directory from git.
2022

2123
Create a new file `Package.swift` in the `root` directory of the repository and add the following configuration.
2224

23-
> Make sure to remove the comment in 'sources'.
25+
> Warning: Make sure to remove the comment in 'sources'.
2426
2527
```swift
2628
// swift-tools-version:5.3
@@ -97,6 +99,8 @@ extern TSLanguage *tree_sitter_{lang}();
9799
98100
In order to add a language to ``CodeEditLanguages`` you need to open the `.xcodeproj` file located inside `CodeLanguage-Container`.
99101
102+
![.xcodeproj location](xcodeproj-location)
103+
100104
1. Add the `tree-sitter` package you created earlier as a dependency like you would in a regular Xcode project.
101105
102106
2. Then make sure the framework target loads the package module.
@@ -107,11 +111,19 @@ In order to add a language to ``CodeEditLanguages`` you need to open the `.xcode
107111
extern TSLanguage *tree_sitter_{lang}();
108112
```
109113
110-
> Please keep an alphabetical order
114+
> Important: Please keep an alphabetical order
111115
112116
4. Now create the `xcframework` by running the `build_framework.sh` script from the Package's root directory.
117+
```bash
118+
$ ./build_framework.sh
119+
```
113120

114121
5. Check the output of the script. It should say `Done!` at the end.
122+
![build_framework.sh console output](build-output)
123+
> Tip: If this does not succeed, try running the script using the `--debug` flag to get verbose output:
124+
> ```bash
125+
> $ ./build_framework.sh --debug
126+
> ```
115127
116128
6. You are now done in the Xcode Project and may close it now. Open the Package and continue.
117129
@@ -148,10 +160,14 @@ private var tsLanguage: UnsafeMutablePointer<TSLanguage>? {
148160
On the bottom of the file add a new `static` constant:
149161
150162
```swift
151-
static let {lang}: CodeLanguage = .init(id: .{lang}, tsName: {lang}, extensions: [...])
163+
static let {lang}: CodeLanguage = .init(
164+
id: .{lang},
165+
tsName: {lang},
166+
extensions: [...]
167+
)
152168
```
153169
154-
> in 'extensions' add the proper file extensions your language uses.
170+
> Important: in 'extensions' add the proper file extensions your language uses.
155171
156172
Now find the static constant ``CodeLanguage/allLanguages`` and add your language to it:
157173
@@ -192,7 +208,7 @@ Make sure to test the newly created language in a sample project!
192208
193209
When everything is working correctly push your `tree-sitter-{lang}` changes to `origin` and also create a Pull Request to the official repository.
194210
195-
> Take [this PR description](https://github.com/tree-sitter/tree-sitter-javascript/pull/223) as a template and cross-reference it with your Pull Request.
211+
> Tip: Take [this PR description](https://github.com/tree-sitter/tree-sitter-javascript/pull/223) as a template and cross-reference it with your Pull Request.
196212
197213
Now you can remove the local dependencies and replace it with the actual package URLs and submit a Pull Request for `CodeEditTextView`.
198214
@@ -224,6 +240,12 @@ Also make sure to add test cases for your new language in `Tests/CodeEditLanguag
224240
}
225241
```
226242
243+
### Run Tests locally
244+
245+
Once you added your unit test cases run all tests locally on your machine by going to `Product>Test` or pressing `⌘+U` to make sure everything is working as intended.
246+
![unit test results](tests-results)
247+
227248
## Documentation
228249
229-
Please make sure to add the newly created properties to the documentation `*.md` files.
250+
Please make sure to add the newly created properties to the documentation `*.md` files in the `Documentation.docc` catalog.
251+
![docs location](docs-location)

Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let fileURL = URL(fileURLWithPath: "/path/to/file.swift")
1515
let language = CodeLanguage.detectLanguageFrom(url: fileURL)
1616
```
1717

18-
> In case the language is not supported yet, the resulting ``CodeLanguage`` will be ``default`` (plain text).
18+
> Important: In case the language is not supported yet, the resulting ``CodeLanguage`` will be ``default`` (plain text).
1919
2020
### Supported Languages
2121

Sources/CodeEditLanguages/Documentation.docc/Documentation.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ A collection of `tree-sitter` languages for syntax highlighting.
44

55
## Overview
66

7-
This package includes a binary framework `CodeLanguagesContainer.xcframework` which bundles all languages as a binary.
7+
![logo](codeeditlanguages-logo)
8+
9+
This package includes a binary framework `CodeLanguagesContainer.xcframework` which bundles all `tree-sitter` languages in a single binary to greatly reduce SPM package resolution times.
810

911
The languages are then served as a ``CodeLanguage``.
1012

13+
## SwiftTreeSitter
14+
15+
This package heavily depends on [SwiftTreeSitter](https://github.com/ChimeHQ/SwiftTreeSitter) by [Matt Massicotte](https://twitter.com/mattie).
16+
1117
## Topics
1218

1319
### Guides
1420

1521
- <doc:Add-Languages>
22+
- <doc:Update-Languages>
1623

1724
### Structs
1825

52.2 KB
Loading
51.5 KB
Loading
38.8 KB
Loading
21.4 KB
Loading

0 commit comments

Comments
 (0)