Skip to content

Commit

Permalink
V1.0.0 (#68)
Browse files Browse the repository at this point in the history
* Pull master to v1.0.0 (#67)

* Fix bug when no new_tokens exist (#61)

* Fix bug when no new_tokens exist

if no new_tokens existed it would not give out any new tokens since the overwrite method did not have anything to compare against.

* Format

* Bump version

* Add Docs (#66)

* Create .readthedocs.yaml

* Exclude docs branch from normal actions

* Try making some changes

* Continue work on docs

* Continue work on docs

* Fix builds

* Add mkdocs and format

* Pip install?

* Try using sphinx

* Fix command

* Finish the docs

* Update README to outsource docs

* Re-bump version

* Revert docs actions changes and change job names

* Revert "Re-bump version"

This reverts commit 3a84012.

* Revert "Revert docs actions changes and change job names"

This reverts commit 1b141c3.

* Bump version (again)

* Revert docs actions changes and change job names

* Tree sitter (#62)

* Create POC

* Improve POC

* Bug fixes, comments, use assert

* Have helpful auto-mapper

The auto-mapper is great for users who don't want to spend forever mapping stuff so it will give a mapping made from what context it can get and then the user can refine it and hone it

* Format

* Move functions to separate file and write tests

Make the tests more official and move the functions to its own file to decouple the tests

* Add comments, rename function and arguments

* Move tests to test folder, funcs to highlight folder

* Update dependencies

* Add requirements-dev.txt and add pycharm to gitignore

* Improve spelling and imports

* I figured it out :D

* Create tree_sitter_highlight()

* Make special tokens function

* Split up tests

* Format

* Try working on adding to API

* Format

* Show crash in actions and ruff

* Even more formatting

* Fix the c pointer bug

* Get working server output

* Reformat

* Add examples and update README

* Format

* isort again

* Add support for .so files

* Add .so tests

* Fix mapping test comments

* Update docs to match tree sitter highlighting

* Bump version in docs

* Try adding epub

* Keep only the epub file

* Specify builders

* Try one-lining this

* Print dir

* Try another way

* Revert "Merge branch 'master' into v1.0.0"

This reverts commit 3bd2e83, reversing
changes made to e85a8eb.

* Change from Salve IPC to Salve

* Appease formatters

I accidentally removed a newline when pulling master to the v1.0.0 branch

* Update highlight example to not be ridiculous

* Use dirhtml for docs

* Logging (#70)

* Create POC

* Add most of the logging and fix setup.py

I still need to give logging to the Tree Sitter part

* Add logs to Tree Sitter highlight and format

* Fix tests

* Use salve dependency hub (#71)

* Use salve dependency hub

* Update docs

* Spell checks and start work on improving docs

* Further improvements to docs

* Add examples and improve small things

* Remove tabs

* Update salve_dependency_hub

* Update docs and examples

* Token bugfix and add test

Sometimes it would try overwriting tokens it shouldn't and DOTALL got all the comment regexes to work properly

* Format

* Use .extend instead of += (#72)

* Update links

* Remove tree sitter (#75)

* Start removing Tree Sitter Code

Commit 1 in a series removing Tree Sitter Support from Salve in favor of Albero.

* Run basic formatting

Commit 2 in a series removing Tree Sitter Support from Salve in favor of Albero.

* Update tests

Commit 3 in a series removing Tree Sitter Support from Salve in favor of Albero.

* Remove Tree Sitter mentions from docs

Commit 4 in a series removing Tree Sitter Support from Salve in favor of Albero.

* Update gitignore

* Update docs

* Use token_tools

* Links and chars standalone (#77)

* Move links and hidden chars file

* Make links and hidden chars standalone

* Fix bug and tests

* Windows being annoying

* Update docs

* Format
  • Loading branch information
Moosems authored Jul 26, 2024
1 parent 196b14e commit 99a1ed7
Show file tree
Hide file tree
Showing 50 changed files with 492 additions and 444 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Black Formatting

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
formatting-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,6 +13,5 @@ jobs:

- name: Code Formatting (App)
run: |
pip install black
pip install -r requirements.txt
pip install -r requirements-dev.txt
black --check .
11 changes: 4 additions & 7 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Isort Formatting

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
formatting-isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -15,6 +13,5 @@ jobs:

- name: Code Formatting (App)
run: |
pip install isort
pip install -r requirements.txt
pip install -r requirements-dev.txt
isort --check .
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
pip install -r requirements-dev.txt
- name: Build and publish to Pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/ruff-format.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Ruff Formatting

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
formatting-ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,6 +13,5 @@ jobs:

- name: Code Formatting (App)
run: |
pip install ruff
pip install -r requirements.txt
pip install -r requirements-dev.txt
ruff format --check .
11 changes: 4 additions & 7 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Ruff Check

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
ruff-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -15,6 +13,5 @@ jobs:

- name: Code Formatting (App)
run: |
pip install ruff
pip install -r requirements.txt
pip install -r requirements-dev.txt
ruff check .
10 changes: 4 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Code Tests

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,5 +14,5 @@ jobs:
- name: Run tests
run: |
pip install .
pip install pytest
pip install -r requirements-dev.txt
python3 -m pytest .
10 changes: 4 additions & 6 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Code Tests (On Windows)

on:
push:
branches:
- "!docs"
on: push

jobs:
formatting:
testing-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -16,5 +14,5 @@ jobs:
- name: Run tests
run: |
pip install .
pip install pytest
pip install -r requirements-dev.txt
python3 -m pytest . -s
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
__pycache__/
dist/
build/
.pytest_cache/
.ruff_cache/
salve.egg-info/

# Pycharm
.idea
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:
commands:
- python3 ./docs/source/create_example_docs.py
- python3 -m pip install -r docs/requirements.txt
- python3 -m sphinx docs/source $READTHEDOCS_OUTPUT/html
- python3 -m sphinx --builder dirhtml docs/source $READTHEDOCS_OUTPUT/html

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">Salve v0.7.2</h1>
<h1 align="center">Salve v1.0.0</h1>

# Installation

Expand All @@ -9,7 +9,7 @@ In the Command Line, paste the following: `pip install salve`
Salve is an IPC library that can be used by code editors to easily get autocompletions, replacements, editorconfig suggestions, definitions, and syntax highlighting.

> **Notes:**
> - Due to the way Windows handles chars the hidden character highlighter may not work properly. See [#57](https://github.com/Moosems/salve/pull/57). If anyone knows how to fix this, I would greatly appreciate you opening a PR :)
> - Due to the way Windows handles chars the hidden character highlighter may not work properly. See [#57](https://github.com/salve-org/salve/pull/57). If anyone knows how to fix this, I would greatly appreciate you opening a PR :)
## Documentation

Expand Down
8 changes: 6 additions & 2 deletions docs/source/command-sheet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Below is a chart outlining the different request commands you can give and the d
* - ``AUTOCOMPLETE``
- file: ``str``,

current_word: ``str`` (optional),
current_word: ``str`` (the portion of the word being typed),

expected_keywords: ``list[str]`` (any special keywords for the language (optional))
* - ``REPLACEMENTS``
Expand All @@ -36,5 +36,9 @@ Below is a chart outlining the different request commands you can give and the d
current_word: ``str`` (the word being searched for),

definition_starters: ``list[tuple[str, str]]`` (list of regexes to search for and a string associated (see :doc:`examples/simple_definitions_example`))
* - ``LINKS_AND_CHARS``
- file: ``str``,

text_range: ``tuple[int, int]`` (the lower and upper line bounds (inclusively) of what text to highlight (optional))

To see how to use any given one of these in more detail, visit the :doc:`examples` page! To continue on your journey through ``Salve`` instead, move on to the :doc:`special-classes` page instead.
To see how to use any given one of these in more detail, visit the :doc:`examples` page! Otherwise move on to the :doc:`special-classes` page instead.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project = "Salve"
copyright = "2024, Moosems"
author = "Moosems"
release = "v0.7.2"
release = "v1.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/create_example_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
for line in example_file:
rst_file.write(f" {line}")
rst_file.write(
f"\nSee the file example file `here <{'https://github.com/Moosems/salve/blob/master/examples/' + filename}>`_."
f"\nSee the file example file `here <{'https://github.com/salve-org/salve/blob/master/examples/' + filename}>`_."
)
48 changes: 19 additions & 29 deletions docs/source/example-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,47 @@ Now that you have ``Salve`` installed, let's try running a simple example that p
from time import sleep
# We import the IPC class, the HIGHLIGHT command, and the Response TypedDict
# NOTE: The HIGHLIGHT is actually just a string but it makes it easier to get
# spelling errors from your code editor
# NOTE: The HIGHLIGHT variable is actually just a string that makes it easier to get
# spell checking from your code editor
from salve import HIGHLIGHT, IPC, Response
# Because this module is made with multiprocessing we need any usage to
# initially be called from an if __name__ == "__main__" clause
def main():
# Here we define the context (create the other process) nothing more. IPC
# doesn't take any arguments, it just sets itself up for you!
# Here we define the context (which creates the other process).
context = IPC()
# In order to actually use a file, we need to update the internal system
# which is done by IPC.update_file(). As promised, this system is also highly
# powerful and flexible and because of this nothign prevents you, the user,
# from using arbitrary code snippets instead of real files.
# In order to actually use a file, we need to update the internal file system
# which is done by IPC.update_file(). Note that nothing prevents you, the
# user, from using arbitrary code snippets instead of real files.
context.update_file(
"test", # Name the file for the system
open(__file__, "r+").read(), # Give the contents as a string
)
# Next, we request the system to make highlights (using the HIGHLIGHT)
# command, tell it to use the file "test", that it should be highlighting
# for a python file, and to only return the code in lines 1-30. If you
# want it to highlight the whole file given , just leave the argument
# empty (unspecified)
# Next, we request the system to make syntax highlights. If you want it to
# highlight the whole file given , just leave the text_range argument unspecified
context.request(
HIGHLIGHT, file="test", language="python", text_range=(1, 30)
)
# It doesn't actually take a full second to get highlights but its simpler
# for the example to just do this.
# Letting the other process spin up and create syntax highlights
sleep(1)
# The reason you need a union of Response and None is because we choose to
# give None when yo ask for the highlight of something that hasn't had a server
# response rather than raise an exception.
# If there is no response we give None instead of raising an Exception
output: Response | None = context.get_response(HIGHLIGHT)
print(output)
# Finally, if you are done with the IPC before the rest of the program, you can
# kill it like so. It automatically dies when the main thread dies but this lets
# you save a bit of CPU usage
# kill it to save a bit of CPU time.
context.kill_IPC()
# Because this module is made with multiprocessing we need an if __name__ == "__main__" clause
if __name__ == "__main__":
main()
Now I know thats a lot of comments, it is, but it also explains everything in a lot of detail.

In a more realistic case, you would probably do something more like the following:
Now thats all fine and dandy, but what about if I need it to work for [insert random use case here]? Well, ``Salve`` is actually meant to be super flexible so if you use it properly, it can elegantly fit nearly any use case. For example, what if you need it to fit a tkinter application that uses an event loop? Well, take a look:

.. code-block:: python
Expand All @@ -77,6 +65,8 @@ In a more realistic case, you would probably do something more like the followin
self.context = IPC()
# At some point something calls the request_highlight function
# In a real application we would also define a callback to send the
# output to
self.after(500, lambda: self.request_highlight(open(__file__, "r+").read()))
self.output: Response | None = None
Expand All @@ -99,15 +89,15 @@ In a more realistic case, you would probably do something more like the followin
if __name__ == "__main__":
App()
Befor you leave, here are some quick reminders to remember as you use ``Salve``:
Some quick notes to remember as you use ``Salve``:

- The first time that the system is loaded or a new server needs to be started it will take a fair bit longer.
- Any usage of ``IPC ``needs to originally have been called from an ``if __name__ == "__main__":`` block to prevent a multiproccesing error.
- The first time that the system is loaded or a new server needs to be started it will take a fair bit longer as a new interpreter needs to be created.
- Any usage of ``IPC`` needs to have been called from an ``if __name__ == "__main__":`` block to prevent a multiproccesing error.

.. |br| raw:: html

<br />

|br|

Now that is one beautiful application! Of course, there is far more that you can do beyond just getting highlights. For example: what if you want to get autocompletions? Well, there is of course the the handy :doc:`command-sheet` page.
Of course, you can do far more with ``Salve`` than just getting syntax highlights. For example: what if you want to get autocompletions? Well, there is of course the the :doc:`command-sheet`.
2 changes: 1 addition & 1 deletion docs/source/examples/example_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ Example Usage
if __name__ == "__main__":
main()
See the file example file `here <https://github.com/Moosems/salve/blob/master/examples/example_usage.py>`_.
See the file example file `here <https://github.com/salve-org/salve/blob/master/examples/example_usage.py>`_.
2 changes: 1 addition & 1 deletion docs/source/examples/gui_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Gui Client
if __name__ == "__main__":
main()
See the file example file `here <https://github.com/Moosems/salve/blob/master/examples/gui_client.py>`_.
See the file example file `here <https://github.com/salve-org/salve/blob/master/examples/gui_client.py>`_.
43 changes: 43 additions & 0 deletions docs/source/examples/highlight_logging_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
=========================
Highlight Logging Example
=========================

.. code-block:: python
from logging import INFO, Logger, basicConfig, getLogger
from time import sleep
from salve import HIGHLIGHT, IPC, Response
basicConfig(
level=INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger: Logger = getLogger("Main")
def main():
context = IPC()
context.update_file(
"test",
open(__file__, "r+").read(),
)
context.request(
HIGHLIGHT, file="test", language="python", text_range=(1, 30)
)
sleep(1)
output: Response | None = context.get_response(HIGHLIGHT)
if output is None:
logger.info("Output is None")
logger.info(f"Output: {output}")
context.kill_IPC()
if __name__ == "__main__":
main()
See the file example file `here <https://github.com/salve-org/salve/blob/master/examples/highlight_logging_example.py>`_.
2 changes: 1 addition & 1 deletion docs/source/examples/simple_autocomplete_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Simple Autocomplete Example
if __name__ == "__main__":
main()
See the file example file `here <https://github.com/Moosems/salve/blob/master/examples/simple_autocomplete_example.py>`_.
See the file example file `here <https://github.com/salve-org/salve/blob/master/examples/simple_autocomplete_example.py>`_.
2 changes: 1 addition & 1 deletion docs/source/examples/simple_definitions_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Simple Definitions Example
if __name__ == "__main__":
main()
See the file example file `here <https://github.com/Moosems/salve/blob/master/examples/simple_definitions_example.py>`_.
See the file example file `here <https://github.com/salve-org/salve/blob/master/examples/simple_definitions_example.py>`_.
Loading

0 comments on commit 99a1ed7

Please sign in to comment.