julia icon indicating copy to clipboard operation
julia copied to clipboard

Assume that docstring code with no lang is julia

Open tecosaur opened this issue 1 year ago • 3 comments

By making this assumption when parsing docstrings, we can remove the assumption that all no-lang Markdown code blocks are in fact Julia without compromising docstring highlighting.

tecosaur avatar Aug 11 '24 15:08 tecosaur

:+1:, this seems better to me

KristofferC avatar Aug 13 '24 12:08 KristofferC

Although doing it like Documenter where only the first code block is assumed to be Julia might be even better. The doctests etc later typically have jldoctest on them.

KristofferC avatar Aug 13 '24 15:08 KristofferC

Personally "the default code language in Julia docstrings is Julia" makes sense to me, I'm not sure if it would be a good idea to restrict it to the first code block only or not?

I know code I've written there are instances where I've used indentation for Julia code multiple times, but I don't have a good sense off the top of my head of the general situation.

tecosaur avatar Aug 18 '24 12:08 tecosaur

Is this the reason why

image

displays without any visual indication that MyNumber is code?

GunnarFarneback avatar May 04 '25 13:05 GunnarFarneback

It's related, yup. The reason why is because the current highlighting rules don't apply any styling to it.

There are at least three routes we can take to changing this:

  1. Giving all code blocks a default colour (you can try styled"{code:$(highlight(\"my code\"))}" to see how this would work)
  2. Adding styling to identifiers
  3. Adding some sort of indicator of codeblocks beside colour (e.g. a vertical line on the left)

tecosaur avatar May 04 '25 13:05 tecosaur

Something would be good since this is an unfortunate regression from 1.11.

image

GunnarFarneback avatar May 04 '25 13:05 GunnarFarneback

Yea, I've run into this myself. Is anything negatively affected beside just the single-symbol headers in markdown code blocks?

Nothing comes to mind, but that seems worth considering when picking between 1/2/3/something else.

tecosaur avatar May 04 '25 14:05 tecosaur

This was the case I ran into in the wild. The generalization MyInt <: MyNumber is also unstyled.

GunnarFarneback avatar May 04 '25 16:05 GunnarFarneback