-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pulling Abstract Trees into 2.0 (#198)
* CompatHelper: add new compat entry for WordTokenizers at version 0.5, (keep existing compat) (#171) Co-authored-by: CompatHelper Julia <[email protected]> * Stack traces (#179) * styling * now excludes other installed packages + fmt and tests * small improvements ot hidden frames * format and docs * small fixes * fmt * kwarg func call fmt * show each error line code * covergage * stacktrace formatting * traces rendering improvements * test fix * new text reshaping function from chatgpt * fixed tests * cleanup * cleanup * bump * bump * bump * prompt init * small fixes to repr and error * fixed small repr bugs * removed deps * wip errors * method error kwargs call * parsed kwargs calls in stackrace * fixes * method error edge cases * bump * bump * bump * fixed textlen bug for orphaned tags * Update Project.toml * Update Project.toml * errors with no backtrace are now shown * logger doesn't cut msgs * CI fix * error msg panel now always shows * reworked logs rendering code * msg reshaping * refactored stacktrace code + further logs improvements * fixed bug with markdown rendering * Link renderable development (#180) * bump * bump * working on making Link work * functional link? * fixing them errors * fixed behavior of hidden frames in stacktrace and docs * fixed bugs * bugs fixed and more test * bugfix * tests fix * tests fixing * tests fix * tests fix * Fix #181 (#182) * small fixes * bump * `Prompt` (#175) * prompt init * small fixes to repr and error * fixed small repr bugs * removed deps * wip errors * bump * bump * bump * bump * prompt wip * bump * prompt almost finished * added tests and docs for prompt * bump * coverage and CI * docs fix * Update _error_messages.jl * Annotations (#185) * init * more extensive precompilation * small fixes for error IO * 204 method invalidation at startup ops * bump * working on annotation * added style * bump * disabled precompilation * new code reshaping function * new annotation system * tests for annotations passing * fmt * more tests * bump * bump * ci fix * bump Co-authored-by: Federico Claudi <[email protected]> * Create Invalidations.yml * Create unused_dependencies.yml * Update Invalidations.yml * Update Invalidations.yml * Update CI.yml * Update CI.yml * Coverage - adding more tests (#186) * increasing test coverage * fixed bug with markup tags including newline * test coverage * bump * bump * bump * bump * bump * CI fix * CI fix * CI fix * CI fix * bump * Update CI.yml * bump * refactored tree * CI fix * docs * Update unused_dependencies.yml * ci fix * Update Invalidations.yml * removed fillin(segments) * Update CI.yml * fmt * bump * removed error message functionality, using base * bump * fix_markup_across_lines (#188) * fix_markup_across_lines * tests passing * fixed small things * bump * wip for fix_ansi_across_lines * fixed nested style tags * reshaping with ANSI and markup works well * fmt * bump * bump * bump * removed unused funcs * docstring * small fixes * bump * Update CI.yml * Working on pre-compilation (#173) * init * more extensive precompilation * small fixes for error IO * 204 method invalidation at startup ops * bump * cleaned up precompilation * removed deps * bump Co-authored-by: Federico Claudi <[email protected]> * CompatHelper: add new compat entry for AbstractTrees at version 0.4, (keep existing compat) (#189) Co-authored-by: CompatHelper Julia <[email protected]> * bump * no stdout in precomp (#191) * no stdout in precomp * ignore precompilation code in coverage * finished re-factoring tree * CI fix --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Rémi Vezy <[email protected]> Co-authored-by: Federico Claudi <[email protected]>
- Loading branch information
1 parent
7593c16
commit d3e94a1
Showing
678 changed files
with
7,550 additions
and
2,560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Invalidations | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- ready_for_review | ||
|
||
concurrency: | ||
# Skip intermediate builds: always. | ||
# Cancel intermediate builds: always. | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
evaluate: | ||
# Only run on PRs to the default branch. | ||
# In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch | ||
if: github.base_ref == github.event.repository.default_branch | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: '1' | ||
- uses: actions/checkout@v3 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-invalidations@v1 | ||
id: invs_pr | ||
|
||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.repository.default_branch }} | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-invalidations@v1 | ||
id: invs_default | ||
|
||
|
||
- name: Report invalidation counts | ||
run: | | ||
echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY | ||
echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY | ||
- name: Check if the PR does increase number of invalidations | ||
if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Check for unused dependencies | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- ready_for_review | ||
|
||
|
||
jobs: | ||
treeshake: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: 1 | ||
- uses: julia-actions/julia-buildpkg@v1 | ||
- uses: julia-actions/julia-treeshake@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
name = "Term" | ||
uuid = "22787eb5-b846-44ae-b979-8e399b8463ab" | ||
authors = ["FedeClaudi <[email protected]> and contributors"] | ||
version = "1.1.1" | ||
version = "1.2.0" | ||
|
||
[deps] | ||
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" | ||
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Highlights = "eafb193a-b7ab-5a9e-9068-77385905fa72" | ||
|
@@ -19,9 +20,9 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | |
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | ||
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" | ||
UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1" | ||
WordTokenizers = "796a5d58-b03d-544a-977e-18100b691f6e" | ||
|
||
[compat] | ||
AbstractTrees = "0.4" | ||
CodeTracking = "1" | ||
Highlights = "0.5" | ||
MyterialColors = "0.3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
ignore: | ||
- "./src/errors.jl" | ||
- "./src/_errors.jl" | ||
- "./src/__precompilation.jl" | ||
- "./test" | ||
- "./scripts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Annotations | ||
```@meta | ||
CurrentModule = Term.Annotations | ||
``` | ||
|
||
|
||
```@index | ||
Pages = ["api_annotations.md"] | ||
``` | ||
|
||
```@autodocs | ||
Modules = [Annotations] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Prompts | ||
```@meta | ||
CurrentModule = Term.Prompts | ||
``` | ||
|
||
|
||
```@index | ||
Pages = ["api_prompt.md"] | ||
``` | ||
|
||
|
||
```@autodocs | ||
Modules = [Prompts] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Prompt | ||
|
||
Time for a little example of a simple thing you can use `Term.jl` for: asking for some input. Use a `Prompt`, ask a question, get an answer. Simple, but a little extra style. That's what `AbstractPrompt` types are for. There's a few different flavors, which we'll look at in due time, but essentially a prompt is made of a bit of text, the `prompt` that is displayed to the user, and some machinery to capture the user's input and parse it/ validate it. | ||
|
||
For example: | ||
|
||
```@example prompt | ||
using Term.Prompts | ||
prompt = Prompt("Simple, right?"); | ||
``` | ||
|
||
creates a `Prompt` object and `ask` then prints the propmt and asks for input: | ||
```julia | ||
prompt |> ask | ||
``` | ||
the output should look something like | ||
```@example prompt | ||
print(prompt) # hide | ||
``` | ||
|
||
here we construct a basic `Prompt` and "ask" it: print the message and capture the reply. `ask` returns the answer, which you can do with as you please. A small warning before we carry on: | ||
|
||
!!! warning "Using VSCode" | ||
As you can see [here](https://discourse.julialang.org/t/vscode-errors-with-user-input-readline/75097/4?u=fedeclaudi), `readlines`, which `AbstractPrompts` use to get the user's input, is a bit troublesome in VSCode. In VSCode, after the prompt gets printed you need to enter "space" (hit the space bar) and then enter and **after** that you can enter your actual replies. | ||
|
||
## Prompt flavours | ||
There's a couple more ways you can use prompts like. One is to ensure you get an answer of the correct `Type`, using the immaginatively names `TypePrompt`: | ||
|
||
```@example prompt | ||
# this only accepts `Int`s | ||
prompt = TypePrompt(Int, "give me a number") # don't forget to |> ask | ||
print(prompt) # hide | ||
``` | ||
|
||
|
||
If your answer can't be converted to the correct type you'll get a `AnswerValidationError`, not good. | ||
|
||
|
||
So, what if you want to get user inputs, but you don't want to handle any crazy input they can provide? Fear not, use `OptionsPrompt` so that only acceptable options will be ok. This will keep "asking" your prompt until the user's answer matches one of the given options | ||
|
||
```@example prompt | ||
prompt = OptionsPrompt(["a lot", "so much", "the most"], "How likely would you be to recomend Term.jl to a friend or colleague?") # don't forget to |> ask | ||
print(prompt) # hide | ||
``` | ||
|
||
Okay, so much typing though. Let's be realistic, most likely you just want to ask a yes/no question and the answer is likely just yes. So just use a `DefaultPrompt`: | ||
|
||
```@example prompt | ||
# one says the first option is the default | ||
prompt = DefaultPrompt(["yes", "no"], 1, "Confirm?") # don't forget to |> ask | ||
print(prompt) # hide | ||
``` | ||
|
||
still too much typing? You can just use the `confirm` function which is equivalent to asking the prompt shown above. | ||
|
||
|
||
## Style | ||
The style of prompt elements (e.g. the color of the prompt's text or of the options) is defined in `Theme`. You can also pass style information during prompt creation: | ||
|
||
```@example prompt | ||
Prompt("Do you like this color?", "red") |> println | ||
DefaultPrompt(["yes", "no"], 1, "Confirm?", "green", "blue", "red") |> println | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# [Annotation](@id AnnotationDocs) | ||
|
||
I could describe what an `Annotation` is, but it's easier to show it: | ||
```@example ann | ||
using Term.Annotations | ||
Annotation( | ||
"This is the main text to annotate", | ||
"main"=>"by main we mean most important, the rest is annotations", | ||
"annotate"=>"annotations are just extra bits of info" | ||
) | ||
``` | ||
|
||
as you can see, `Panel`s with extra messages are displayed underneath the main bit of text. | ||
Each "annotation" is defined by `Pair`, the first element of the `Pair` is a substring of the | ||
main text indicating what we want to annotate. The second element is used to specify what we | ||
want to annotate it with. | ||
|
||
If you want to assign some `Style` information to each annotation, you can specify that by using a `Tuple{String, String}` as second element of the `Annotation` `Pair`. In this tuple, the first part refers to the annotation message while the second can store style information. | ||
|
||
```@example ann | ||
Annotation("this has some style", "style"=>("style means color or stuff like bold", "bold red")) | ||
``` | ||
|
||
and of course you can mix your normal `markup` style too: | ||
Annotation("{bold italic}this{/bold italic} has some style", "style"=>("style means {bright_blue}color{/bright_blue} or stuff like {bold}bold{/bold}", "bold red")). | ||
|
||
--- | ||
|
||
`Annotation` objects are `AbstractRenderables`, so you can mix and match them with other things too. | ||
```@example ann | ||
import Term: Panel, highlight_syntax | ||
code = highlight_syntax("Annotation(\"main text\", \"main\"=>\"most important\")") | ||
Panel( | ||
Annotation(code, "\"main text\""=>"main message to be annotated", "\"main\"=>\"most important\""=>"annotation"); | ||
padding=(4, 4, 2, 1), | ||
title="Annotation: usage", fit=true, title_style="default green bold", | ||
title_justify=:center, style="green dim" | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.