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

Use Yul lexer in docs #8778

Merged
merged 1 commit into from Apr 27, 2020
Merged

Conversation

veox
Copy link
Contributor

@veox veox commented Apr 26, 2020

Update pygments-lexer-solidity dependency in docs, so Yul can be highlighted separately from Solidity.

This changes all instances of code to code-block in yul.rst, with explicit language specification; highlight is intentionally not used. See commit a481ea7 for reasoning.

Closes #8608 as implemented.

Note:

code is a generic reStructuredText's directive; and Sphinx promotes code-block instead; and code isn't even mentioned in Sphinx's docs - although it's included, and "works", but differently than code-block; quite confusing to dig through while figuring "why X isn't working".

@axic
Copy link
Member

axic commented Apr 26, 2020

Thanks! I was considering changing all the random uses of code/code-block to highlights:. What do you think?

@veox
Copy link
Contributor Author

veox commented Apr 26, 2020

That would work, although I'm not sure that's the intended use. IDK really, no strong opinion.


... Or it might not, if highlight doesn't understand none - see next comment.

@veox
Copy link
Contributor Author

veox commented Apr 26, 2020

Ah, peg became available in pygments v2.6, but the doc builder uses v2.3.1.

That's a shame, it looked nice. Guess none it is then. :(


Argh! That didn't work:

Warning, treated as error:
/root/project/docs/yul.rst:430:Cannot analyze code. No Pygments lexer found for "none".

Trying code-block instead of code: that's where I picked up none from.


An alternative would be to build the docs in a virtualenv, but that's outside the scope of the PR.

@veox veox changed the title Use Yul lexer in docs (plus a few semi-related doc fixes) [WIP] Use Yul lexer in docs (plus a few semi-related doc fixes) Apr 26, 2020
@veox
Copy link
Contributor Author

veox commented Apr 26, 2020

The doc-job failings keep happening because of disparities between my local Sphinx (v3.0.2) and what CI is using (v1.8.5).

I'll try to fix it silently, and rewrite the PR description.


For the b_osx failure, we'll have to wait until after May 3 (my free-tier plan broke CircleCI, apparently 😆), or someone with a better plan will have to take over, because I've expended my MacOS X limit.


Unsquashed git history in this branch of mine.

Many commits squashed; turns out that with the combination of:

* Python v2.7,
* Sphinx v1.8.5, and
* Pygments v2.3.1

versions (old!) used in the CI, the only viable approach is:

* to use `code-block` directives with explicit language specification,
* to provide no file-local default using `highlight`, and
* to set language as `none` for grammar specifications.

Underlying are the following issues (again, for the old versions
listed above):

* Generic RST `code` doesn't work when language is `none`:

    Warning, treated as error:
    /root/project/docs/yul.rst:430:Cannot analyze code. No Pygments lexer found for "none".

  Additionally, it might be trying to fall back to the default
  (Solidity) if left unspecified.

* If a file-local default is specified using `highlight`, then
  `code-block` _must_ also provide a language:

    Warning, treated as error:
    /root/project/docs/yul.rst:185:Error in "code-block" directive:
    1 argument(s) required, 0 supplied.

* Sphinx seems to try the file-local default "yul" (specified with
  `highlight`) on `code` marked having language `json`:

    Warning, treated as error:
    /root/project/docs/yul.rst:130:Could not lex literal_block as "yul". Highlighting skipped.

* The only well-lexed highlighter for two of the three grammar
  specifications is `peg`, but it was added in Pygments v2.6.
  One of the grammars - in the "Formal Specification" section,
  the one after "We will use a destructuring notation for the
  AST nodes." - _must_ be left unhighlighted, with language set
  to `none`: all lexers do really poorly.

... And one should never, ever start treating warnings as mere
warnings, without having exhausted all other options.

Otherwise, it's a slippery slope, - and look where that brought
Gandhi: to being a strawman in every lousy argument to be had!..
@veox veox changed the title [WIP] Use Yul lexer in docs (plus a few semi-related doc fixes) Use Yul lexer in docs Apr 26, 2020
@veox
Copy link
Contributor Author

veox commented Apr 26, 2020

This ended up more difficult than expected; but is now otherwise "done".

I'll poke CircleCI in a week for the b_osx job if no one gets there first.


Also, I'd now really advise against using highlight for code blocks. I've never seen anyone do it, and I wouldn't wish figuring out why on anyone.

@chriseth
Copy link
Contributor

I'll push this over to a branch in the Solidity repo to get a macos run

@chriseth
Copy link
Contributor

Actually, b_osx is fully unrelated to this.

@chriseth
Copy link
Contributor

Thanks a lot for your help!

@chriseth chriseth merged commit 77a086b into ethereum:develop Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yul support in Pygments
3 participants