Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion for references #648

Open
jens-auer opened this issue Oct 14, 2022 · 7 comments
Open

Autocompletion for references #648

jens-auer opened this issue Oct 14, 2022 · 7 comments
Labels
💬 discussion Disccussion on new features, projects, etc... ✨ enhancement

Comments

@jens-auer
Copy link

Similar to autocompletion for image and include files (#377), I would like to use autocompletion for internal and external references.

Details:

  • Start typing << and an autosuggest should offer IDs in the current document
  • Start typing xref: and an autosuggest should offer asciidoc files in the project. If the user selects a file foo.adoc, it should autocomplete to xref:foo.adoc# and then autosuggest IDs in the target document

Background:
We import requirements from a requirement management tool and reference them in the text. Autocomplete would reduce errors and provide better efficiency.

@jens-auer jens-auer added ✨ enhancement 💬 discussion Disccussion on new features, projects, etc... labels Oct 14, 2022
@ggrossetie
Copy link
Member

Are you talking specifically about Antora xref or AsciiDoc xref?

@jens-auer
Copy link
Author

@kharann
Copy link

kharann commented Oct 31, 2022

Agreed! This would be a nice feature :)))

@apupier
Copy link
Member

apupier commented Nov 4, 2022

The IDs that can be referenced are these ones? https://docs.asciidoctor.org/asciidoc/latest/attributes/id/

@Mogztter Do we already have an utility parsing .adoc files to retrieve all IDs of a document?

I think that we can split this task with:

  • Create utility method to retrieve IDs in a document
    • for simple case, only id defined in square bracket with shorthand syntax #
    • for simple case, only id defined in square bracket with longhand syntax id=
    • for simple case, only id defined in double square brackets with legacy syntax
    • for most advanced case when there are other things in square brackets like roles [quote.movie#roads,Dr. Emmett Brown]
  • Provide completion in the same document after typing <<
  • Propose completion in the same document when starting a word proposing the <<id>> ?
  • Provide completion for other document in the workspace when typing xref: (should we restrict to .adoc document?) But maybe this one will need to be discussed a bit more because I feel like there are different ways to do it https://docs.asciidoctor.org/pdf-converter/latest/interdocument-xrefs/
  • Provide completion for ids in referenced document when typing xref:my.adoc#

@ggrossetie
Copy link
Member

Do we already have an utility parsing .adoc files to retrieve all IDs of a document?

I guess you can load the document and retrieve anchors using the catalog:

The processor always cataloged the following assets, regardless of this setting:
block or inline anchors (key: :refs)
(...)
https://docs.asciidoctor.org/asciidoctor/latest/api/catalog-assets/#what-assets-are-cataloged

@ggrossetie
Copy link
Member

Provide completion for other document in the workspace when typing xref: (should we restrict to .adoc document?)

Yes I think we should restrict to .adoc. This file extension will most likely be used in the mime-type registration.

apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 18, 2022
part of asciidoctor#648

- it was broken during enforcing code style, the regular expression was
not correctly converted
asciidoctor@cd477c7
- added a test
- The previous was not very nice in the sense that it is not inserting
the file path but only the label, but maybe it is enough if there is the
right include?

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 18, 2022
longhand notation

I.e. with [#myId] and [id=myId]

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
@apupier
Copy link
Member

apupier commented Nov 25, 2022

After I discovered that some part was already implemented and based on first feedback on my 2 initial pull requests, Here is a new proposal to the split of tasks:

apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 25, 2022
longhand notation

I.e. with [#myId] and [id=myId]

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 25, 2022
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 25, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 25, 2022
one test provided when at same level

todo:
- test with file at different level
- implement the feature :-)

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 26, 2022
longhand notation

I.e. with [#myId] and [id=myId]

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 26, 2022
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 26, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Nov 26, 2022
one test provided when at same level

todo:
- test with file at different level
- implement the feature :-)

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
ggrossetie pushed a commit that referenced this issue Dec 23, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Dec 23, 2022
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Jan 3, 2023
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Jan 3, 2023
apupier added a commit to apupier/asciidoctor-vscode that referenced this issue Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 discussion Disccussion on new features, projects, etc... ✨ enhancement
Projects
None yet
Development

No branches or pull requests

4 participants