zazuko / vscode-sparql-notebook

Visual Studio Code SPARQL Notebook Extension
https://marketplace.visualstudio.com/items?itemName=Zazuko.sparql-notebook
Other
26 stars 8 forks source link

Features 12-2023 #70

Open BenjaminHofstetter opened 10 months ago

BenjaminHofstetter commented 10 months ago

Things to think of:

vhorvath commented 10 months ago

I was also thinking about PREFIX handling myself. I really like the extension, however it is inconvenient that PREFIXes must be repeated across cells in a notebook even though the same context is being used.

My current workaround

I currently use a keyboard shortcut to collapse the long series of prefixes in a cell: CTRL+K+[ to define the collapsible region. The only problem is that if another line is to be added to the region and that falls outside the predefined region, then the collapsible region needs to be redefined, and the collapsible regions don't copy/paste.

Idea 1: Context management

It would be great to implement a mechanism to delegate PREFIXes (or other repeated content) into contexts that could be utilized across other cells. I was thinking about adding special comment sections, see blow.

# <global>
PREFIX ...
PREFIX ...
# </global>

This could also be combined with the host definition via comment, like so:

# <global endpoint="./relative/path/file.ttl">
PREFIX ...
PREFIX ...
# </global>

Using XML style notation could allow for utilizing an existing language and its features to define contexts, and to include additional features as the extension evolves. Existing syntax for in cell endpoint definition could be preserved for compatibility.

Users could create cells to define contexts and upon execution they would be stored globally.

Recall of contexts in other cell:

# <global/>
# <other_context/>

The downside to this approach is that the recall of a context is opaque. We can't readily inspect what's in it at the time of recall. A collapsible view could be added to the cell's output section, that is collapsed by default but expanded on request to inspect the actual query as it was submitted to the endpoint. This view could feature a copy button so that the full query could be extracted.

Idea 2: Collapsible prefixes

Alternatively, (auto) collapse/expand feature could be implemented in the editor for the PREFIXes (similarly to the mechanism of Apache Fuseki) this way the delegation into a global context could be avoided, but cells could be a bit more succinct, and collapse could be enabled for 5 or more subsequent PREFIXes.

Downside to this approach is that the PREFIXes are hidden and definitions must be repeated, and if they need change across many cells, it is harder to update them all at once.

Could lend a hand with the implementation if specifications can be defined.