Code Monkey home page Code Monkey logo

Comments (11)

bashtage avatar bashtage commented on May 20, 2024 1

https://github.com/sphinx-doc/sphinx/blob/af62fa61e6cbd88d0798963211e73e5ba0d55e6d/sphinx/environment/collectors/title.py#L53

Does not seem to provide a method to override.

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

Can you be a bit more specific? In particular, can you posted the relevant parts of your conf and the rst page?

from sphinx-material.

cglacet avatar cglacet commented on May 20, 2024

Hmm, I'm not sure I get what you mean, but here is my a test.rst file:

file without header/title.

And here are the relevant parts of the config.py:

import sphinx_material

project = 'Kune'
release = '0.1'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx_copybutton',
]

html_sidebars = {
    "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]
}

extensions.append("sphinx_material")
html_theme_path = sphinx_material.html_theme_path()
html_context = sphinx_material.get_html_context()
html_theme = "sphinx_material"

html_theme_options = {
    'nav_title': 'Kune servers documentation',
    'globaltoc_depth': 3,
    'globaltoc_collapse': True,
    'globaltoc_includehidden': True,
}

Using this configuration, the resulting HTML tag is <title>&lt;no title&gt; — Kune 0.1 documentation</title>.

I would like to know how to make the resulting tag <title>Kune 0.1 documentation</title> or any other title I could decide to be the default title for no-headings-pages.

EDIT, also, I guess you already know that, if I set html_title = "Another title" I'll get <title>&lt;no title&gt; — Another title</title> which doesn't solve the "<no title>" problem.

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

This seems to be Sphinx's default for a page with no title. This "title" (<no title>) is then passed to the template engine which is then rendered in place fo the title.

This could be addressed here, but it may not be the right place for a fix. Sphinx might be the right place to have an option to override the default value of <no title> to be an empty string.

Normally the title is read from the pages top heading.

from sphinx-material.

cglacet avatar cglacet commented on May 20, 2024

Thanks, I'll move this to sphinx then and patch it on my side in the mean time.

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

Great. I'd rather not try and fitis here since it would be pretty hacky, something along the lines of

if title =! "<no title>":
    full_title = title + " - ' + html_title

which is very dependent on how sphinx renders "no title". I would suggest that Sphinx could add an enhancement for conf.py that would be something like include_empty_page_title which would be True or False. Alternatively, it could just have a default page title, e.g., default_page_title = "" which would then be reasonable to filter for so that title would only be added when not-empty.

from sphinx-material.

cglacet avatar cglacet commented on May 20, 2024

That patch is not enough sadly, there is another place that treats title apparently.

Here is how I patched it (at least to remove the <no title> part), in my conf.py:

from docutils import nodes
from sphinx.application import Sphinx
from sphinx.environment.collectors.title import TitleCollector

_process_doc = TitleCollector.process_doc

def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
    if doctree.traverse(nodes.section):
        _process_doc(self, app, doctree)
    else:
        titlenode = nodes.title()
        app.env.titles[app.env.docname] = titlenode
        app.env.longtitles[app.env.docname] = titlenode

TitleCollectorprocess_doc = process_doc

This renders — test, for now I can't get rid of the .

Another problem is that, even with setting a title manually in the toctree: A test .rst without any section <test>, the entry doesn't show.

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

The - removal would need to come from sphinx-material. If title is empty, then the page title should be html_title if present, and it not, nothing (which might not be 100% compliant in HTML).

from sphinx-material.

cglacet avatar cglacet commented on May 20, 2024

The title wouldn't be empty, it would be equal to html_title. Here the problem is that it's equal to f"— {html_title}".

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

That is what I mean. One challenge is that html_title has been escaped before it get to templating and the - has been manually inserted, and so some string parsing is needed. Not the end of the world, but starting to feel fragile. This hardcoded behaviour is a misfeature of Sphinx IMO.

from sphinx-material.

bashtage avatar bashtage commented on May 20, 2024

There is a start in#81. It will need to become opt-in before it can be merged.

from sphinx-material.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.