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

Allow alternate stylesheets #1764

Closed
Jellby opened this Issue Mar 10, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@Jellby
Contributor

Jellby commented Mar 10, 2015

I would like to add some alternate stylesheets in a sphinx theme, as described here: http://alistapart.com/article/alternate/

This requires only specifying some "rel" and "title" attributes in the elements, but this part is hardcoded in sphinx/themes/basic/layout.html. I can add more stylesheets, but not specify the attributes. As far as I understand from the jinja documentation the "css()" macro cannot be overridden by child templates, because it's not inside a block.

So, this would, I guess, be easily fixed by adding a block to the parent template, such that I can redefine the "css()" macro, or use a different custom one.

@shimizukawa

This comment has been minimized.

Show comment
Hide comment
@shimizukawa

shimizukawa Mar 10, 2015

Member

You can provide _static/custom.css and write the following codes into "conf.py":

def setup(app): 
    app.add_stylesheet('custom.css') 

refs: http://sphinx-doc.org/extdev/appapi.html#sphinx.application.Sphinx.add_stylesheet

Member

shimizukawa commented Mar 10, 2015

You can provide _static/custom.css and write the following codes into "conf.py":

def setup(app): 
    app.add_stylesheet('custom.css') 

refs: http://sphinx-doc.org/extdev/appapi.html#sphinx.application.Sphinx.add_stylesheet

@Jellby

This comment has been minimized.

Show comment
Hide comment
@Jellby

Jellby Mar 11, 2015

Contributor

I'm afraid that doesn't help. That only adds a standard stylesheet:

<link rel="stylesheet" href="../_static/custom.css" type="text/css" />

But I want to add something like:

<link rel="alternate stylesheet" href="../_static/custom.css" type="text/css" title="Plain" />

(note the different "rel" and "title" attributes.) I'm creating my own modified theme and I'd like to override the css() macro in basic/layout.html, but I cannot because it's not defined or used inside a "block". Another solution, of course, would be to extend the add_stylesheet syntax (and modify the template) to allow specifying "rel" and "title" attributes.

Contributor

Jellby commented Mar 11, 2015

I'm afraid that doesn't help. That only adds a standard stylesheet:

<link rel="stylesheet" href="../_static/custom.css" type="text/css" />

But I want to add something like:

<link rel="alternate stylesheet" href="../_static/custom.css" type="text/css" title="Plain" />

(note the different "rel" and "title" attributes.) I'm creating my own modified theme and I'd like to override the css() macro in basic/layout.html, but I cannot because it's not defined or used inside a "block". Another solution, of course, would be to extend the add_stylesheet syntax (and modify the template) to allow specifying "rel" and "title" attributes.

@shimizukawa

This comment has been minimized.

Show comment
Hide comment
@shimizukawa

shimizukawa Mar 11, 2015

Member

Hum.. I think it'll be resolved if

  • a, add_styleseet() accepts attributes like rel="alternate stylesheet" and title="Plain"
  • b, css() jinja2 macro is defined in some named block (if it is possible)

For now, as you mentioned, these features are not implemented.

Member

shimizukawa commented Mar 11, 2015

Hum.. I think it'll be resolved if

  • a, add_styleseet() accepts attributes like rel="alternate stylesheet" and title="Plain"
  • b, css() jinja2 macro is defined in some named block (if it is possible)

For now, as you mentioned, these features are not implemented.

@lehmannro

This comment has been minimized.

Show comment
Hide comment
@lehmannro

lehmannro Mar 11, 2015

Contributor

You can currently do something like this with the extrahead block, see eg. the pyramid theme for an example.

As for the API, I think rel= is not necessary as it should default to alternate stylesheet if a title is given. I'm not sure what you mean by (b); css_files should just be an list of objects/tuples having a path and an optional title instead of a list of bare path strings.

Contributor

lehmannro commented Mar 11, 2015

You can currently do something like this with the extrahead block, see eg. the pyramid theme for an example.

As for the API, I think rel= is not necessary as it should default to alternate stylesheet if a title is given. I'm not sure what you mean by (b); css_files should just be an list of objects/tuples having a path and an optional title instead of a list of bare path strings.

@Jellby

This comment has been minimized.

Show comment
Hide comment
@Jellby

Jellby Mar 11, 2015

Contributor

The extrahead block may help.

Even with the default as alternate stylesheet if a title is given, it should be possible to provide a title and just stylesheet too. The (b) solution means simply allowing an override of the css() macro, which is currently not possible.

Contributor

Jellby commented Mar 11, 2015

The extrahead block may help.

Even with the default as alternate stylesheet if a title is given, it should be possible to provide a title and just stylesheet too. The (b) solution means simply allowing an override of the css() macro, which is currently not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment