Skip to content

Better support for multiple glossaries #1399

Open

Description

@shimizukawa

You can use the glossary directive multiple times in a documentation without problems when you never define the same word twice.

This makes it possible to have a glossary with subtitles for topics eg.

I wonder if anyone ever had the need to put more than one glossary into the documentation. Maybe domain specific glossaries? One for math terms and one for chemical terms.

If this is a realistic usecase it would be nice to label the glossaries so that I can specify where a term belongs to. Maybe some kind of indicator as we use with the domains.

Example:

#!rst

.. glossary:: math

   term
      (definition)

This is a :math:term:`term`for my math specific glossary

Activity

  1. added
    type:enhancement
    type:proposal
    on Jan 3, 2015
  2. christophercrouzet commented on Jan 9, 2017

    @christophercrouzet

    To add to this issue, I'm currently writing a page with a list of categories and their definitions. I thought that the glossary directive would be a good fit since, as per its dictionary definition, I indeed have “an alphabetical list of words relating to a specific subject, text, or dialect, with explanations”. On top of that, the glossary directive makes it easy to link individually to each category. But then what if I end up writing an other glossary to globally define some terms?

  3. LuckyResistor commented on Feb 5, 2021

    @LuckyResistor

    I'm writing extensive documentation using sphinx. Some commonly used modules are included as shared resources into these documentations. Having glossaries in this included documentation would help a lot. At the moment, this is not possible, because terms used in these included parts can always cause conflicts.

    I see two simple solutions:

    • Merging glossary terms from multiple sources into one central glossary with priorities.
    • Allow separate glossaries with an additional identifier.

    Reasons for Multiple Glossaries

    • Extensive documentation covering different fields with conflicting terminologies (design, math, coding). The same term has a different meaning in different parts of the documentation.
    • Modular documentation with inserted documentation parts. E.g. three applications use the same library to provide some functionality. The documentation for this functionality is included in the documentation of the main application.

    Merging with Priorities

    .. glossary::
        :priority: secondary
    
        term
            Secondary definition
    
        foo
            Foo definition
    
    .. glossaty::
        :priority: main
    
        term
            Primary definition
    
        bar
            Bar definition
    

    Result

    term
    Primary definition

    bar
    Bar definition

    foo
    Foo definition

    Secondary definitions are never rendered at the original place where they are defined but in the main glossary.

    Separate Glossaries with Identifiers

    Text with own :term:`terms<myid:term>`
    
    .. glossary:: myid
        
        term
            Term definition
    
  4. arwedus commented on Nov 28, 2021

    @arwedus

    In a large project, we have:

    • one glossary for administrative terms
    • one glossary for common (project wide) definitions
    • one glossary for process, method and tools stuff
    • one glossary for test terminology
    • one glossary for each subsystem

    A term must only appear once in one of those glossaries. What I am looking for is a "glossary of glossaries" page, i.e. a merged glossary term index. Is that possible with Sphinx as of today?

  5. added this to the some future version milestone on Sep 29, 2022
  6. ixjlyons commented on Jul 6, 2026

    @ixjlyons

    An additional case where you might have multiple glossaries with overloaded/conflicting terms: intersphinx.

    I would like to have intersphinx for linking to e.g. API docs for multiple dependencies and would also like to use :term: to refer to a glossary definition in one of them that happens to also be present in the other. A workaround appears to be defining the term in my own glossary which then links directly to the desired external term anchor URL, but it's unclear if that precedence is explicit or an implementation detail.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:enhancementtype:proposal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions