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

Add project: highlight yaml examples #369

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

humitos
Copy link
Member

@humitos humitos commented Jun 6, 2024

I used highlight.js to highlight the examples when importing a project. It requires importing a CSS file that I'm not sure where to put it yet.

https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/dark.min.css

Besides, I need to know where to place the small chunk of JS code that I added to make this work.

Screenshot_2024-06-06_14-02-30

@agjohnson I would appreciate some directions here to clean up and finish this work.

Based on #368

I used tabs to show different examples of YAML files, as suggested in #184.
It looks great for an initial interactive approach.

I like the tabs over the dropdown because it gives the user a clear idea there
are more than Sphinx and MkDocs tools supported, which is a good marketing
strategy, in my opinion.

It also adds an "Others" option that's more generic and shows how to use
`build.commands` in a generic way: install dependencies, build, copy assets
under `$READTHDOCS_OUTPUT` directory.
I used `highlight.js` to highlight the examples when importing a project.
It requires importing a CSS file that I'm not sure where to put it yet.

https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/dark.min.css

Besides, I need to know where to place the small chunk of JS code that I added
to make this work.

Based on #368
@humitos
Copy link
Member Author

humitos commented Jun 6, 2024

I moved the code where I think it belongs. The only missing piece here is understanding how to include my CSS stylesheet file. Other than that, it seems that everything works as expected 👍🏼

@humitos
Copy link
Member Author

humitos commented Jun 6, 2024

Boom! I figured it out!

@humitos humitos marked this pull request as ready for review June 6, 2024 15:09
@humitos humitos requested a review from a team as a code owner June 6, 2024 15:09
@humitos humitos requested a review from agjohnson June 6, 2024 15:09
Comment on lines +42 to +43
<pre>
<code id="project-create-sample-sphinx" class="language-yaml highlight">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highlight.js requires this to be pre > code and not the other way around 🤷🏼

@agjohnson
Copy link
Contributor

agjohnson commented Jun 6, 2024

We are already using Pygments on the server side in other places. We should very likely continue with that pattern, I don't feel we should have two ways of highlighting.

You can see the integration HTTP exchange UI, templates, and views for examples of this. I'm guessing it will plug in easily here as well.

Here's one spot:

The pygments support in our theme already went through the process of matching the color theme too, which would also be required to support highlight.js.

@agjohnson
Copy link
Contributor

agjohnson commented Jun 6, 2024

Noted on the original issue too, the plan when this UI was first added was to come back and switch the examples with tabbed menus and use Pygments for highlighting:

A pygments solution would probably work best with a template filter, given these examples are hardcoded in templates. django-pygments might give us this already.

Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should have noted my feedback in review here. I think Pygments is the better option here, it doesn't need anything horribly new and will match where we've used Pygments in other UIs.

@humitos
Copy link
Member Author

humitos commented Jun 10, 2024

OK. The original issue said that either worked: pygments or a front-end solution. I will come back to this once I have some extra time and check the pygments solution. However, I will de-prioritize this work for now.

@agjohnson
Copy link
Contributor

Adding a front end dependency works if pygments doesn't work for some reason, but it helps to keep patterns the same and dependencies minimal on the front end side if we can.

Base automatically changed from humitos/yaml-examples-import-project to main June 10, 2024 21:24
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.

2 participants