Skip to content

Conversation

@aidanfnv
Copy link
Contributor

@aidanfnv aidanfnv commented Apr 29, 2025

Fixes #67

This change prepares this repo to be used in a readthedocs project for hosting the Slang Documentation in a single place.

The setup and theming are based on the existing SlangPy readthedocs site (https://slangpy.shader-slang.org/en/latest/), but with the primary difference being that this change also adds 2 Python scripts for post-processing the html build outputs. This post processing is necessary because Sphinx/readthedocs does not assume that relative paths without file extensions should resolve to .html link, and although there is an option to set it up so that it does make that assumption, it will not work with links with anchors.
The debug prints in the script would only be visible in the readthedocs build logs.

Currently the table of contents links to the documents in this repo, as well as the docs in the Slang Standard Module Reference, with other docs like the Slang User Guide to be added in the future. For now, those links go out to the existing docs website on GitHub Pages.

This commit adds files required to build a readthedocs project from this repo, based on the readthedocs project for SlangPy
@aidanfnv
Copy link
Contributor Author

I have built a preview of the readthedocs site resulting from this change: https://slang-documentation.readthedocs.io/en/latest/

@aidanfnv aidanfnv changed the title Setup readthedocs in this repo Set up readthedocs in this shader-slang.github.io Apr 30, 2025
@aidanfnv aidanfnv changed the title Set up readthedocs in this shader-slang.github.io Set up readthedocs in shader-slang.github.io Apr 30, 2025
Copy link
Contributor

@jkwak-work jkwak-work left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

This script is basically performing string replacement for two cases.
It can be simplified in two lines of bash script something like the following.

  # Fix href="#../path/to/file#fragment"
  sed -i -E 's/href=(["\'])#(\.\.\/[^"\']+?)#([^"\']+?)\1/href=\1\2.html#\3\1/g' external/std-reference/*.html

  # Fix href="#../path/to/file"
  sed -i -E 's/href=(["\'])#(\.\.\/[^"\'#]+?)\1/href=\1\2.html\1/g' external/std-reference/*.html

I am wondering why we need this type of fix-up in the first place.
Maybe we should make some modifications on how std-reference repo generates the document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The stdlib-reference (with my doc writer change) generates the documents and their paths correctly, but readthedocs does not resolve those paths correctly when it builds its html output. I'm not sure why you can't have relative paths and fragments at the same time, but when readthedocs cannot resolve a path like that, it instead treats the whole path as a fragment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I'll simplify that script. Much of the complication was from debugging the link replacement process.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well. I wasn't suggesting to use shell script approach.
It was just to double check my understanding...
I think python is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, I meant that I'll clean up the python script to remove anything extraneous that I added.

@jkwak-work
Copy link
Contributor

jkwak-work commented Apr 30, 2025

I can see some descriptions for each title in the current webpage.
But the new page doesn't show them.
Is it intentional? or WIP?

I am talking about this, as an example,

User Guide
The guide provides an introduction to the Slang language and its major features, as well as the compilation and reflection API.

image

@aidanfnv
Copy link
Contributor Author

Ah, I should have made my intention clear with that. I was thinking that the links on the current webpage link should be changed to point to the relevant sections of the readthedocs site, and that the new index page should not replace the current webpage.

This commit changes the sidebar to link to https://shader-slang.org/docs/ instead of index.rst, which is primarily used to populate the sidebar table of contents
@jkwak-work
Copy link
Contributor

Ah, I should have made my intention clear with that. I was thinking that the links on the current webpage link should be changed to point to the relevant sections of the readthedocs site, and that the new index page should not replace the current webpage.

Ok. That makes sense.

@aidanfnv
Copy link
Contributor Author

aidanfnv commented Apr 30, 2025

With the latest commits, the "Standard Modules Reference" link on https://shader-slang.org/docs/ will be changed to the Standard Modules Reference page at https://slang-documentation.readthedocs.io/page/external/stdlib-reference/. RTD redirects page/* paths to the equivalent page in the default language and default RTD branch.

I also added a redirect to index.rst, so that navigating to the relatively empty index page will redirect to the current index page at https://shader-slang.org/docs/

However, maybe we do not want those 2 commits right now and instead the links should be changed once all of the docs are included?

@jkwak-work
Copy link
Contributor

Why don't we want to merge the change as soon as possible?
Would it replace the docs currently available?

@aidanfnv
Copy link
Contributor Author

aidanfnv commented May 1, 2025

The commit previous to the last replaces our link to the stdlib-reference docs on the main docs page. Technically, it's out of the scope of this PR, and we probably should not relink it to the readthedocs site until they, so I'll revert it.

@aidanfnv aidanfnv merged commit 21b5bde into shader-slang:main May 1, 2025
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.

Set up readthedocs in shader-slang.github.io

2 participants