Skip to content

Commit 381ed80

Browse files
committed
update documentation
- added 'Update-Languages.md' - enhanced other doc files
1 parent a15dfd4 commit 381ed80

File tree

10 files changed

+82
-9
lines changed

10 files changed

+82
-9
lines changed

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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A collection of `tree-sitter` languages for syntax highlighting.
44

55
## Overview
66

7+
![logo](codeeditlanguages-logo)
8+
79
This package includes a binary framework `CodeLanguagesContainer.xcframework` which bundles all languages as a binary.
810

911
The languages are then served as a ``CodeLanguage``.
@@ -13,6 +15,7 @@ The languages are then served as a ``CodeLanguage``.
1315
### Guides
1416

1517
- <doc:Add-Languages>
18+
- <doc:Update-Languages>
1619

1720
### Structs
1821

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

Sources/CodeEditLanguages/Documentation.docc/TreeSitterModel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Since fetching queries *can* be expensive the queries are fetched lazily and kept in memory for the entire session.
66

7-
> Be aware that running the application in `Debug` configuration will lead to worse performance. Make sure to run it in `Release` configuration.
7+
> Warning: Be aware that running the application in `Debug` configuration will lead to worse performance. Make sure to run it in `Release` configuration.
88
99
## Usage
1010

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Update-Languages
2+
3+
This article covers all the steps needed to update to the latest version of the `tree-sitter` languages
4+
5+
## Overview
6+
7+
From time to time the `tree-sitter` languages need to be updated to their latest version. This is pretty straight forward and can be done in less than 5 minutes.
8+
9+
## Update the Dependencies
10+
11+
1. Open the `CodeLanguages-Container.xcodeproj` which is located inside the `./CodeLanguages-Container` directory.
12+
![xcodeproj location](xcodeproj-location)
13+
14+
2. Go to `File > Packages > Update to Latest Package Versions` and let it resolve the SPM dependencies.
15+
> Note: Depending on your internet connection and Mac hardware this step can take a couple of minutes.
16+
17+
3. Close the project
18+
19+
> Tip: At this stage you can check if anything changed at all by checking the git status. If `Package.resolved` does not appear in the changed files list, you don't need to proceed.
20+
> ```bash
21+
> $ git status
22+
> ```
23+
24+
## Update the Framework
25+
26+
1. Open your terminal and set your working directory
27+
```bash
28+
$ cd path/to/CodeEditLanguages
29+
```
30+
31+
2. Run the `build_framework.sh` script
32+
```bash
33+
$ ./build_framework.sh
34+
```
35+
> Note: This script automatically removes old artifacts and replaces them with the new ones.
36+
37+
3. Check the console output. It should say `Done!` at the end.
38+
![build output](build-output)
39+
> Tip: If you don't get the output and the script terminates early, there might be an issue. Try running the script again with the `--debug` flag appended:
40+
> ```bash
41+
> $ ./build_framework.sh --debug
42+
> ```
43+
44+
## Check if everything still works
45+
46+
1. Open the ``CodeEditLanguages`` Package in Xcode and run the included unit tests.
47+
48+
2. Once all the tests succeeded, the changes can be committed, pushed and a pull request can be opened.

0 commit comments

Comments
 (0)