-
Notifications
You must be signed in to change notification settings - Fork 29
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
Include common files like autosummary templates and gallery.css in the theme itself #262
Comments
…302) Part of #262. Before, to add translation support, you would have to copy and paste `versionutils.py`. Now, you ~only need to define `translations_list` in `conf.py` and `qiskit_sphinx_theme` will set up the rest for you. That duplication of `versionutils.py` was annoying to copy and also made it too easy to fall out of sync, resulting in #272. To prove this works, this PR removes `language_utils.py` from `example_docs/` and instead sets its values in `conf.py`. Translations still work: <img width="753" alt="Screenshot 2023-05-05 at 1 13 59 PM" src="https://user-images.githubusercontent.com/14852634/236549631-2f844db4-8ff6-49e7-9ef0-af1cbbcb5c43.png"> This PR intentionally does not refactor any of the `translations.py` code. It only copies and pastes what we had from all our projects, to make it easier to review. The only divergences are: * Removing the `translations` config option and HTML context. It wasn't being used by anything. * Removing the `current_translation` HTML context. It wasn't being used by anything.
I had ChatGPT write a script to group which projects have the same files. First, I cloned all the Qiskit projects locally, then ran group_files.py
import os
import hashlib
# Function to calculate MD5 Hash
def hash_file(filepath):
hasher = hashlib.md5()
with open(filepath, 'rb') as f:
buf = f.read()
hasher.update(buf)
return hasher.hexdigest()
# Read file paths from files.txt
with open('files.txt', 'r') as f:
files = [line.strip() for line in f]
# Dictionary to store hash: [files]
file_groups = {}
for file in files:
file_hash = hash_file(file)
if file_hash in file_groups:
file_groups[file_hash].append(file)
else:
file_groups[file_hash] = [file]
# Print out the groups of identical files
group_number = 1
for file_group in file_groups.values():
print(f"Group {group_number}:")
for file in file_group:
print(file)
print()
group_number += 1 No divergences
|
I couldn't get de-duplication of autosummary templates to work in #317. But I also realize I'm not certain how desirable it is. For example, I personally do not like how we do API references and would like to explore changes in the future. That is harder for us to explore if we have standardized everything in qiskit_sphinx_theme. That is, finalize the design before standardization. -- #318 will allow us to DRY -- We already are DRYing -- So, all that's left I believe is removing these three CSS files that I have discovered are stale and should be removed: gallery.css, custom.css, and style.css I'm going through all projects today to clean this up:
|
…opying `no_image.png` (#318) Part of #262. 14 projects are copying around the same `no_image.png` file. It's helpful so that you can set `nbsphinx_thumbnails` to point to it. This PR adds the file to `qiskit_sphinx_theme` so that they can instead use the standard file if they want. They don't have to switch to this file. And repos can also still override `images/logo.png` how they want, e.g. that Metal has it be a Metal specific logo currently. Their override will take precedence. -- Note that we already distribute `static/images/logo.svg`. But `nbsphinx_thumbnails` doesn't work with an SVG. -- This PR also removes `gallery.css` from the example docs. We don't use `sphinx-gallery`, so this was a bad copy and paste.
Right now, Terra and the Metapackage have duplicate templates for autosummary. Should we bundle those in the theme instead?
Theme users could still override our default.
Probably related to this is whether we want to stop having a dedicated page for each method. If we bundled the templates in this theme, how smooth would the migration be?
The text was updated successfully, but these errors were encountered: