rescript-lang / rescript-lang/rescript-vscode

Improving doc comments syntax highlighting in hovering

Aperta
#545 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
ReScript
Stelle
354
Fork
63
Merge medio
11h 29m
PR unite (30g)
1

Descrizione

After #97 and #525 have been merged we can provider basic syntax highlight when hovering.

Current state

image

Apparently vscode does not detect ```res example as rescript syntax. In markdown highlighting works.

image

Proposal

Convert ```res example to rescript. This can be done on the client side `client/src/extension.ts`, but I'm more +1 to do it in analysis bin as it wouldn't affect other clients.

As the return is markdown we could create sections using the word after ```res?

From:

```res example

To:

## Example\n```rescript

Example:

From:

Constructs a RegExp object (Js.Re.t) from a `string`.
Regex literals `%re("/.../")` should generally be preferred, but `fromString`
is useful when you need to dynamically construct a regex using strings,
exactly like when you do so in JavaScript.

```res example
let firstReScriptFileExtension = (filename, content) => {
  let result = Js.Re.fromString(filename ++ "\.(res|resi)")->Js.Re.exec_(content)
  switch result {
  | Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])
  | None => None
  }
}

// outputs "res"
firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js")
```

To:

Constructs a RegExp object (Js.Re.t) from a `string`.
Regex literals `%re("/.../")` should generally be preferred, but `fromString`
is useful when you need to dynamically construct a regex using strings,
exactly like when you do so in JavaScript.

## Example

```rescript
let firstReScriptFileExtension = (filename, content) => {
  let result = Js.Re.fromString(filename ++ "\.(res|resi)")->Js.Re.exec_(content)
  switch result {
  | Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])
  | None => None
  }
}

// outputs "res"
firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js")
```

Below an example after convert res to rescript. Note: indentation at the beginning of the line are preserved, we must remove them.

image

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia ispezionando la gestione dell’hover in client/src/extension.ts e il percorso analysis bin proposto nell’issue. Traccia come viene assemblato il markdown dell’hover, inclusi i blocchi delimitati e l’indentazione. Il lavoro è completato quando i blocchi di esempio res vengono visualizzati come sintassi rescript con una sezione Example e l’indentazione del contenuto conservato viene rimossa come richiesto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
developer-experience
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.