Skip to content

Enhance filtering based on keyword tags in libdoc html page #5619

Open

Description

@robinmackaij

Background

OpenApiTools allows users to generate a custom library with keywords based on the OpenAPI spec used in generation. This library subclasses OpenApiLibCore that exposes 26 keywords.

When the library documentation for this custom library is generated, all the keywords are part of the html doc (ordered alphabetically). This is confusing for the user; while the OpenApiLibCore keywords are available through the custom library, the user of the custom library shouldn't generally need them.

To provide more clear documentation for custom libraries that subclass other libraries, it would be beneficial to have more options to show / hide keywords in the documentation.

Proposed changes

To allow more flexibility in showing / hiding keywords in the documentation, the following changes are proposed:

  • Change the "show tags" filter (that appears if there are any keywords with tags) from single select to multiselect.
  • Add a Show no tags option to show only keywords that do not have any tags.
  • Introduce a "hide tags" filter similar to the "show tags" filter. By default, no keywords should be hidden. An option to hide all keywords with no tags should be present.

The above changes, in combination with keyword tags within libraries, should allow for more clear documentation for custom libraries.

In addition, it would be beneficial to update the libdoc command to allow passing presets for the filters such that the generated page will open with the desired filters applied.

Activity

  1. mkorpela commented on Feb 25, 2026

    @mkorpela
    Member

    Gemini 3.1 Pro says:
    Here is the complete implementation. I've broken the changes down into targeted file updates using the unified diff format where applicable, and full file contents where necessary.

    1. Update the libdoc CLI command options

    We define two new arguments (--showtag and --hidetag) supporting multiple values (via * token parsing in RF's ArgumentParser).

    # FILE: src/robot/libdoc.py
    <<<<
        --language lang       Set the default language used in HTML outputs.
                              `lang` must be one of the built-in language codes:
    {format_languages()}
                              New in RF 7.2.
     -n --name name           Sets the name of the documented library or resource.
    ====
        --language lang       Set the default language used in HTML outputs.
                              `lang` must be one of the built-in language codes:
    {format_languages()}
                              New in RF 7.2.
        --showtag tag *       Show only keywords with these tags in HTML documentation.
                              New in RF 7.x.
        --hidetag tag *       Hide keywords with these tags in HTML documentation.
                              New in RF 7.x.
     -n --name name           Sets the name of the documented library or resource.
    >>>>
    # FILE: src/robot/libdoc.py
    <<<<
        def main(
            self,
            args,
            name="",
            version="",
            format=None,
            docformat=None,
            specdocformat=None,
            theme=None,
            language=None,
            pythonpath=None,
            quiet=False,
        ):
            if pythonpath:
                sys.path = pythonpath + sys.path
            lib_or_res, output = args[:2]
            docformat = self._get_docformat(docformat)
            libdoc = LibraryDocumentation(lib_or_res, name, version, docformat)
            if ConsoleViewer.handles(output):
                ConsoleViewer(libdoc).view(output, *args[2:])
                return
            format, specdocformat = self._get_format_and_specdocformat(
                format, specdocformat, output
            )
            if (
                format == "HTML"
                or specdocformat == "HTML"
                or (format in ("JSON", "LIBSPEC") and specdocformat != "RAW")
            ):
                libdoc.convert_docs_to_html()
            libdoc.save(
                output,
                format,
                self._validate_theme(theme, format),
                self._validate_lang(language),
            )
            if not quiet:
                self.console(Path(output).absolute())
    ====
        def main(
            self,
            args,
            name="",
            version="",
            format=None,
            docformat=None,
            specdocformat=None,
            theme=None,
            language=None,
            showtag=None,
            hidetag=None,
            pythonpath=None,
            quiet=False,
        ):
            if pythonpath:
                sys.path = pythonpath + sys.path
            lib_or_res, output = args[:2]
            docformat = self._get_docformat(docformat)
            libdoc = LibraryDocumentation(lib_or_res, name, version, docformat)
            if ConsoleViewer.handles(output):
                ConsoleViewer(libdoc).view(output, *args[2:])
                return
            format, specdocformat = self._get_format_and_specdocformat(
                format, specdocformat, output
            )
            if (
                format == "HTML"
                or specdocformat == "HTML"
                or (format in ("JSON", "LIBSPEC") and specdocformat != "RAW")
            ):
                libdoc.convert_docs_to_html()
            libdoc.show_tags = showtag or []
            libdoc.hide_tags = hidetag or []
            libdoc.save(
                output,
                format,
                self._validate_theme(theme, format),
                self._validate_lang(language),
            )
            if not quiet:
                self.console(Path(output).absolute())
    >>>>

    2. Update the LibraryDoc model to accept the preset tags

    # FILE: src/robot/libdocpkg/model.py
    <<<<
            self.type_docs = ()
    ====
            self.type_docs = ()
            self.show_tags = []
            self.hide_tags = []
    >>>>
    # FILE: src/robot/libdocpkg/model.py
    <<<<
            if lang:
                data["lang"] = lang.lower()
            return data
    ====
            if lang:
                data["lang"] = lang.lower()
            if self.show_tags:
                data["showTags"] = self.show_tags
            if self.hide_tags:
                data["hideTags"] = self.hide_tags
            return data
    >>>>

    3. Setup types for TypeScript components

    # FILE: src/web/libdoc/types.ts
    <<<<
      theme: string | null;
      lang: string | null;
    };
    ====
      theme: string | null;
      lang: string | null;
      showTags?: Array<string>;
      hideTags?: Array<string>;
    };
    >>>>
    # FILE: src/web/libdoc/types.ts
    <<<<
    interface RuntimeLibdoc extends Libdoc {
      selectedTag?: string;
      inits: Array<RuntimeKeyword>;
      keywords: Array<RuntimeKeyword>;
    }
    ====
    interface RuntimeLibdoc extends Libdoc {
      selectedShowTags?: Array<string>;
      selectedHideTags?: Array<string>;
      inits: Array<RuntimeKeyword>;
      keywords: Array<RuntimeKeyword>;
    }
    >>>>

    4. Provide Missing Strings to Translation JSON

    Overwriting the entire file to ensure all keys like "noTags", "showTags", and "hideTags" exist cleanly in all configured languages.

    # FILE: src/web/libdoc/i18n/translations.json
    {
      "en": {
        "code": "en",
        "intro": "Introduction",
        "libVersion": "Library version",
        "libScope": "Library scope",
        "importing": "Importing",
        "arguments": "Arguments",
        "doc": "Documentation",
        "keywords": "Keywords",
        "tags": "Tags",
        "noTags": "No tags",
        "showTags": "Show tags",
        "hideTags": "Hide tags",
        "returnType": "Return Type",
        "kwLink": "Link to this keyword",
        "argName": "Argument name",
        "varArgs": "Variable number of arguments",
        "varNamedArgs": "Variable number of named arguments",
        "namedOnlyArg": "Named only argument",
        "posOnlyArg": "Positional only argument",
        "defaultTitle": "Default value that is used if no value is given",
        "typeInfoDialog": "Click to show type information",
        "search": "Search",
        "dataTypes": "Data types",
        "allowedValues": "Allowed Values",
        "dictStructure": "Dictionary Structure",
        "convertedTypes": "Converted Types",
        "usages": "Usages",
        "generatedBy": "Generated by",
        "on": "on",
        "chooseLanguage": "Choose language"
      },
      "fi": {
        "code": "fi",
        "intro": "Johdanto",
        "libVersion": "Kirjaston versio",
        "libScope": "Kirjaston laajuus",
        "importing": "Käyttöönotto",
        "arguments": "Argumentit",
        "doc": "Dokumentaatio",
        "keywords": "Avainsanat",
        "tags": "Tagit",
        "noTags": "Ei tageja",
        "showTags": "Näytä tagit",
        "hideTags": "Piilota tagit",
        "returnType": "Paluuarvo",
        "kwLink": "Linkki tähän avainsanaan",
        "argName": "Argumentin nimi",
        "varArgs": "Vaihteleva määrä argumentteja",
        "varNamedArgs": "Vaihteleva määrä nimettyjä argumentteja",
        "namedOnlyArg": "Vain nimettyjä argumentteja",
        "posOnlyArg": "Vain positionaalisia argumentteja",
        "defaultTitle": "Oletusarvo, jota käytetään jos arvoa ei anneta",
        "typeInfoDialog": "Näytä tyyppitieto",
        "search": "Etsi",
        "dataTypes": "Datatyypit",
        "allowedValues": "Sallitut arvot",
        "dictStructure": "Sanakirjarakenne",
        "convertedTypes": "Muunnetut tyypit",
        "usages": "Käyttöpaikat",
        "generatedBy": "Luotu",
        "on": "",
        "chooseLanguage": "Valitse kieli"
      },
      "fr": {
        "code": "fr",
        "intro": "Introduction",
        "libVersion": "Version de la bibliothèque",
        "libScope": "Portée de la bibliothèque",
        "importing": "Importation",
        "arguments": "Arguments",
        "doc": "Documentation",
        "keywords": "Mots-clés",
        "tags": "Tags",
        "noTags": "Pas de tags",
        "showTags": "Afficher les tags",
        "hideTags": "Masquer les tags",
        "returnType": "Type de retour",
        "kwLink": "Lien vers ce mot-clé",
        "argName": "Nom de l'argument",
        "varArgs": "Nombre variable d'arguments",
        "varNamedArgs": "Nombre variable d'arguments nommés",
        "namedOnlyArg": "Argument nommé uniquement",
        "posOnlyArg": "Argument positionnel uniquement",
        "defaultTitle": "Valeur par défaut utilisée si aucune valeur n'est donnée",
        "typeInfoDialog": "Cliquez pour afficher les informations de type",
        "search": "Rechercher",
        "dataTypes": "Types de données",
        "allowedValues": "Valeurs autorisées",
        "dictStructure": "Structure du dictionnaire",
        "convertedTypes": "Types convertis",
        "usages": "Utilisations",
        "generatedBy": "Généré par",
        "on": "le",
        "chooseLanguage": "Choisir la langue"
      },
      "it": {
        "code": "it",
        "intro": "Introduzione",
        "libVersion": "Versione della libreria",
        "libScope": "Ambito della libreria",
        "importing": "Importazione",
        "arguments": "Argomenti",
        "doc": "Documentazione",
        "keywords": "Parole chiave",
        "tags": "Tag",
        "noTags": "Nessun tag",
        "showTags": "Mostra tag",
        "hideTags": "Nascondi tag",
        "returnType": "Tipo di ritorno",
        "kwLink": "Link a questa parola chiave",
        "argName": "Nome dell'argomento",
        "varArgs": "Numero variabile di argomenti",
        "varNamedArgs": "Numero variabile di argomenti nominati",
        "namedOnlyArg": "Argomento solo nominato",
        "posOnlyArg": "Argomento solo posizionale",
        "defaultTitle": "Valore predefinito utilizzato se non viene fornito un valore",
        "typeInfoDialog": "Clicca per mostrare le informazioni sul tipo",
        "search": "Cerca",
        "dataTypes": "Tipi di dati",
        "allowedValues": "Valori consentiti",
        "dictStructure": "Struttura del dizionario",
        "convertedTypes": "Tipi convertiti",
        "usages": "Utilizzi",
        "generatedBy": "Generato da",
        "on": "su",
        "chooseLanguage": "Scegli la lingua"
      },
      "nl": {
        "code": "nl",
        "intro": "Introductie",
        "libVersion": "Bibliotheekversie",
        "libScope": "Bibliotheekbereik",
        "importing": "Importeren",
        "arguments": "Parameters",
        "doc": "Documentatie",
        "keywords": "Actiewoorden",
        "tags": "Labels",
        "noTags": "Geen labels",
        "showTags": "Toon labels",
        "hideTags": "Verberg labels",
        "returnType": "Andwoord type",
        "kwLink": "Link naar actiewoord",
        "argName": "Benoemde parameters",
        "varArgs": "Variabel aantal parameters",
        "varNamedArgs": "Variable aantal benoemde parameters",
        "namedOnlyArg": "Alleen benoemde parameters",
        "posOnlyArg": "Aleen positionele parameters",
        "defaultTitle": "Standaard waarde welke wordt gebruikt als geen waarde is gegeven",
        "typeInfoDialog": "Klik om informatie over dit type te zien",
        "search": "Zoeken",
        "dataTypes": "Datatypen",
        "allowedValues": "Geldige waarden",
        "dictStructure": "Woordenboek Structuur",
        "convertedTypes": "Geconverteerde typen",
        "usages": "Gebruikt in",
        "generatedBy": "Gegenereerd door",
        "on": "op",
        "chooseLanguage": "Kies taal"
      },
      "pt-br": {
        "code": "pt-BR",
        "intro": "Introdução",
        "libVersion": "Versão da Biblioteca",
        "libScope": "Escopo da Biblioteca",
        "importing": "Importação",
        "arguments": "Argumentos",
        "doc": "Documentação",
        "keywords": "Palavras-Chave",
        "tags": "Etiquetas",
        "noTags": "Sem etiquetas",
        "showTags": "Mostrar etiquetas",
        "hideTags": "Esconder etiquetas",
        "returnType": "Tipo de Retorno",
        "kwLink": "Ligação para a palavra-chave",
        "argName": "Nome do Argumento",
        "varArgs": "Argumentos em quantidade variável",
        "varNamedArgs": "Argumentos nomeados em quantidade variável",
        "namedOnlyArg": "Apenas argumentos nomeados",
        "posOnlyArg": "Apenas argumentos posicionais",
        "defaultTitle": "Valor padrão que é usado se nenhum tiver sido informado",
        "typeInfoDialog": "Clicar para mostrar informação de tipo",
        "search": "Pesquisar",
        "dataTypes": "Tipos de dados",
        "allowedValues": "Valores permitidos",
        "dictStructure": "Estrutura de Dicionário",
        "convertedTypes": "Tipos Convertidos",
        "usages": "Usos",
        "generatedBy": "Gerado por",
        "on": "ligado",
        "chooseLanguage": "Escolher idioma"
      },
      "pt-pt": {
        "code": "pt-PT",
        "intro": "Introdução",
        "libVersion": "Versão da Biblioteca",
        "libScope": "Âmbito da Biblioteca",
        "importing": "Importação",
        "arguments": "Argumentos",
        "doc": "Documentação",
        "keywords": "Palavras-Chave",
        "tags": "Etiquetas",
        "noTags": "Sem etiquetas",
        "showTags": "Mostrar etiquetas",
        "hideTags": "Esconder etiquetas",
        "returnType": "Tipo de Retorno",
        "kwLink": "Ligação para a palavra-chave",
        "argName": "Nome do Argumento",
        "varArgs": "Argumentos em quantidade variável",
        "varNamedArgs": "Argumentos nomeados em quantidade variável",
        "namedOnlyArg": "Apenas argumentos nomeados",
        "posOnlyArg": "Apenas argumentos posicionais",
        "defaultTitle": "Valor por omissão que é usado se nenhum tiver sido dado",
        "typeInfoDialog": "Clicar para mostrar informação de tipo",
        "search": "Procurar",
        "dataTypes": "Tipos de dados",
        "allowedValues": "Valores permitidos",
        "dictStructure": "Estrutura de Dicionário",
        "convertedTypes": "Tipos Convertidos",
        "usages": "Utilização",
        "generatedBy": "Gerado por",
        "on": "ligado",
        "chooseLanguage": "Escolher língua"
      }
    }

    5. Update HTML templates for multiselects

    # FILE: src/web/libdoc/libdoc.html
    <<<<
            {{#if tags.length}}
              <select id="tags-shortcuts-container">
              </select>
            {{/if}}
    ====
            {{#if tags.length}}
              <div class="tags-filters">
                <select id="show-tags-shortcuts-container" multiple title="{{t 'showTags'}}">
                </select>
                <select id="hide-tags-shortcuts-container" multiple title="{{t 'hideTags'}}">
                </select>
              </div>
            {{/if}}
    >>>>
    # FILE: src/web/libdoc/libdoc.html
    <<<<
        <script type="text/x-handlebars-template" id="tags-shortcuts-template">
          <option value="" {{#ifEquals selectedTag ""}}selected{{/ifEquals}}>- Show all tags -</option>
          {{#each tags}}
            <option {{#ifEquals ../selectedTag this}}selected{{/ifEquals}}>{{this}}
            </option>
          {{/each}}
        </script>
    ====
        <script type="text/x-handlebars-template" id="tags-shortcuts-template">
          <option value="[No tags]" {{#ifContains selectedTags "[No tags]"}}selected{{/ifContains}}>{{t "noTags"}}</option>
          {{#each tags}}
            <option value="{{this}}" {{#ifContains ../selectedTags this}}selected{{/ifContains}}>{{this}}
            </option>
          {{/each}}
        </script>
    >>>>

    6. Implement frontend logic in View controller

    # FILE: src/web/libdoc/view.ts
    <<<<
      private initTagSearch() {
        const params = new URLSearchParams(window.location.search);
        let selectedTag = "";
        if (params.has("tag")) {
          selectedTag = params.get("tag")!;
          this.tagSearch(selectedTag, window.location.hash);
        }
        if (this.libdoc.tags.length) {
          this.libdoc.selectedTag = selectedTag;
          this.renderLibdocTemplate("tags-shortcuts");
          document.getElementById("tags-shortcuts-container")!.onchange = (e) => {
            const value = (e.target as HTMLSelectElement).selectedOptions[0].value;
            if (value != "") {
              this.tagSearch(value);
            } else {
              this.clearTagSearch();
            }
          };
        }
      }
    
      private initLanguageMenu() {
    ====
      private initTagSearch() {
        const params = new URLSearchParams(window.location.search);
        let selectedShowTags = this.libdoc.showTags || [];
        let selectedHideTags = this.libdoc.hideTags || [];
        
        if (params.has("showtag")) {
          selectedShowTags = params.getAll("showtag");
        }
        if (params.has("hidetag")) {
          selectedHideTags = params.getAll("hidetag");
        }
    
        if (this.libdoc.tags.length) {
          this.libdoc.selectedShowTags = selectedShowTags;
          this.libdoc.selectedHideTags = selectedHideTags;
          
          this.renderTemplate("tags-shortcuts", { 
              tags: this.libdoc.tags, 
              selectedTags: selectedShowTags 
          }, "#show-tags-shortcuts-container");
          
          this.renderTemplate("tags-shortcuts", { 
              tags: this.libdoc.tags, 
              selectedTags: selectedHideTags 
          }, "#hide-tags-shortcuts-container");
          
          const updateTags = () => {
            const showSelect = document.getElementById("show-tags-shortcuts-container") as HTMLSelectElement;
            const hideSelect = document.getElementById("hide-tags-shortcuts-container") as HTMLSelectElement;
            
            const showVals = Array.from(showSelect.selectedOptions).map(opt => opt.value);
            const hideVals = Array.from(hideSelect.selectedOptions).map(opt => opt.value);
            
            this.tagsSearch(showVals, hideVals, window.location.hash);
          };
    
          document.getElementById("show-tags-shortcuts-container")!.onchange = updateTags;
          document.getElementById("hide-tags-shortcuts-container")!.onchange = updateTags;
          
          if (selectedShowTags.length > 0 || selectedHideTags.length > 0) {
              this.tagsSearch(selectedShowTags, selectedHideTags, window.location.hash);
          }
        }
      }
    
      private initLanguageMenu() {
    >>>>
    # FILE: src/web/libdoc/view.ts
    <<<<
        document.querySelectorAll(".kw-tags span").forEach((elem) => {
          elem.addEventListener("click", (e) => {
            this.tagSearch((e.target! as HTMLSpanElement).innerText);
          });
        });
    ====
        document.querySelectorAll(".kw-tags span").forEach((elem) => {
          elem.addEventListener("click", (e) => {
            const tag = (e.target! as HTMLSpanElement).innerText;
            const showSelect = document.getElementById("show-tags-shortcuts-container") as HTMLSelectElement;
            if (showSelect) {
                Array.from(showSelect.options).forEach(opt => {
                    opt.selected = opt.value === tag;
                });
            }
            const hideSelect = document.getElementById("hide-tags-shortcuts-container") as HTMLSelectElement;
            if (hideSelect) {
                hideSelect.selectedIndex = -1;
            }
            this.tagsSearch([tag], [], window.location.hash);
          });
        });
    >>>>
    # FILE: src/web/libdoc/view.ts
    <<<<
      private tagSearch(tag: string, hash?: string) {
        (
          document.getElementsByClassName("search-input")[0] as HTMLInputElement
        ).value = "";
        const include = { tags: true, tagsExact: true };
        const url = window.location.pathname + "?tag=" + tag + (hash || "");
        this.markMatches(tag, include);
        this.highlightMatches(tag, include);
        history.replaceState && history.replaceState(null, "", url);
        document.getElementById("keyword-shortcuts-container")!.scrollTop = 0;
      }
    
      private clearTagSearch() {
        (
          document.getElementsByClassName("search-input")[0] as HTMLInputElement
        ).value = "";
        history.replaceState &&
          history.replaceState(null, "", window.location.pathname);
        this.resetKeywords();
      }
    
      private searching() {
        this.searchTime = Date.now();
        const value = (
          document.getElementsByClassName("search-input")![0] as HTMLInputElement
        ).value;
        const include = { name: true, args: true, doc: true, tags: true };
    
        if (value) {
          requestAnimationFrame(() => {
            this.markMatches(value, include, this.searchTime, () => {
              this.highlightMatches(value, include, this.searchTime);
              document.getElementById("keyword-shortcuts-container")!.scrollTop = 0;
            });
          });
        } else {
          this.resetKeywords();
        }
      }
    
      private highlightMatches(
    ====
      private tagsSearch(showTags: string[], hideTags: string[], hash?: string) {
        this.libdoc.selectedShowTags = showTags;
        this.libdoc.selectedHideTags = hideTags;
        
        const searchString = (document.getElementsByClassName("search-input")[0] as HTMLInputElement).value;
        
        const params = new URLSearchParams(window.location.search);
        params.delete("showtag");
        params.delete("hidetag");
        showTags.forEach(t => params.append("showtag", t));
        hideTags.forEach(t => params.append("hidetag", t));
        
        let search = params.toString();
        if (search) search = "?" + search;
        const url = window.location.pathname + search + (hash || "");
        
        this.applyFilters(searchString, showTags, hideTags);
        
        if (searchString) {
            this.highlightMatches(searchString, { name: true, args: true, doc: true, tags: true });
        }
        
        history.replaceState && history.replaceState(null, "", url);
        document.getElementById("keyword-shortcuts-container")!.scrollTop = 0;
      }
    
      private searching() {
        this.searchTime = Date.now();
        const searchString = (
          document.getElementsByClassName("search-input")![0] as HTMLInputElement
        ).value;
        
        const showTags = this.libdoc.selectedShowTags || [];
        const hideTags = this.libdoc.selectedHideTags || [];
    
        requestAnimationFrame(() => {
            this.applyFilters(searchString, showTags, hideTags, this.searchTime, () => {
                if (searchString) {
                    this.highlightMatches(searchString, { name: true, args: true, doc: true, tags: true }, this.searchTime);
                }
                document.getElementById("keyword-shortcuts-container")!.scrollTop = 0;
            });
        });
      }
    
      private highlightMatches(
    >>>>
    # FILE: src/web/libdoc/view.ts
    <<<<
      private markMatches(
        pattern: string,
        include: MatchInclude,
        givenSearchTime?: number,
        callback?: FrameRequestCallback,
      ) {
        if (givenSearchTime && givenSearchTime !== this.searchTime) {
          return;
        }
        let patternRegexp = regexpEscape(pattern);
        if (include.tagsExact) {
          patternRegexp = "^" + patternRegexp + "$";
        }
        const regexp = new RegExp(patternRegexp, "i");
        const test = regexp.test.bind(regexp);
        let result = {} as RuntimeLibdoc;
        let keywordMatchCount = 0;
        result.keywords = this.libdoc.keywords.map((orig) => {
          const kw = { ...orig };
          kw.hidden =
            !(include.name && test(kw.name)) &&
            !(include.args && test(kw.args)) &&
            !(include.doc && test(kw.doc)) &&
            !(include.tags && kw.tags.some(test));
          if (!kw.hidden) keywordMatchCount++;
          return kw;
        });
        this.renderLibdocTemplate("keyword-shortcuts", result);
        this.renderKeywords(result);
        if (this.libdoc.tags.length) {
          this.libdoc.selectedTag = include.tagsExact ? pattern : "";
          this.renderLibdocTemplate("tags-shortcuts");
        }
        document.getElementById("keyword-statistics-header")!.innerText =
          keywordMatchCount + " / " + result.keywords.length;
        if (keywordMatchCount === 0)
          (
            document.querySelector("#keywords-container table") as HTMLTableElement
          ).innerHTML = "";
        if (callback) {
          requestAnimationFrame(callback);
        }
      }
    ====
      private applyFilters(
        searchString: string,
        showTags: string[],
        hideTags: string[],
        givenSearchTime?: number,
        callback?: FrameRequestCallback,
      ) {
        if (givenSearchTime && givenSearchTime !== this.searchTime) {
          return;
        }
        
        const hasSearch = searchString.length > 0;
        let searchRegexp: RegExp | null = null;
        if (hasSearch) {
            searchRegexp = new RegExp(regexpEscape(searchString), "i");
        }
        const test = searchRegexp ? searchRegexp.test.bind(searchRegexp) : () => false;
    
        let result = {} as RuntimeLibdoc;
        let keywordMatchCount = 0;
        result.keywords = this.libdoc.keywords.map((orig) => {
          const kw = { ...orig };
          kw.hidden = false;
    
          if (showTags.length > 0) {
              const matchesShow = showTags.some(t => {
                  if (t === "[No tags]") return kw.tags.length === 0;
                  return kw.tags.includes(t);
              });
              if (!matchesShow) kw.hidden = true;
          }
    
          if (hideTags.length > 0) {
              const matchesHide = hideTags.some(t => {
                  if (t === "[No tags]") return kw.tags.length === 0;
                  return kw.tags.includes(t);
              });
              if (matchesHide) kw.hidden = true;
          }
    
          if (hasSearch && !kw.hidden) {
              const matchesSearch = test(kw.name) || test(kw.args) || test(kw.doc) || kw.tags.some(test);
              if (!matchesSearch) kw.hidden = true;
          }
    
          if (!kw.hidden) keywordMatchCount++;
          return kw;
        });
        
        this.renderLibdocTemplate("keyword-shortcuts", result);
        this.renderKeywords(result);
        
        document.getElementById("keyword-statistics-header")!.innerText =
          keywordMatchCount + " / " + result.keywords.length;
        if (keywordMatchCount === 0)
          (
            document.querySelector("#keywords-container table") as HTMLTableElement
          ).innerHTML = "";
        if (callback) {
          requestAnimationFrame(callback);
        }
      }
    >>>>
    # FILE: src/web/libdoc/view.ts
    <<<<
      private resetKeywords() {
        this.renderLibdocTemplate("keyword-shortcuts");
        this.renderKeywords();
        if (this.libdoc.tags.length) {
          this.libdoc.selectedTag = "";
          this.renderLibdocTemplate("tags-shortcuts");
        }
        history.replaceState && history.replaceState(null, "", location.pathname);
      }
    
      private clearSearch() {
        (
          document.getElementsByClassName("search-input")[0] as HTMLInputElement
        ).value = "";
        const tagsSelect = document.getElementById("tags-shortcuts-container");
        if (tagsSelect) {
          (tagsSelect as HTMLSelectElement).selectedIndex = 0;
        }
        this.resetKeywords();
      }
    ====
      private resetKeywords() {
        this.libdoc.selectedShowTags = [];
        this.libdoc.selectedHideTags = [];
        
        const showSelect = document.getElementById("show-tags-shortcuts-container") as HTMLSelectElement;
        if (showSelect) showSelect.selectedIndex = -1;
        
        const hideSelect = document.getElementById("hide-tags-shortcuts-container") as HTMLSelectElement;
        if (hideSelect) hideSelect.selectedIndex = -1;
    
        this.applyFilters("", [], []);
        
        history.replaceState && history.replaceState(null, "", location.pathname);
      }
    
      private clearSearch() {
        (
          document.getElementsByClassName("search-input")[0] as HTMLInputElement
        ).value = "";
        this.resetKeywords();
      }
    >>>>

    To verify:

    1. Verify TypeScript compiles and templates generate correctly: npm run build or the local tool logic to bundle Web.
    2. Generate Libdoc output: python -m robot.libdoc --showtag tag1 --hidetag tag2 SomeLib SomeLib.html
    3. Inspect SomeLib.html and verify the filtering behavior applies on page load and works as multiselect. Ensure "[No tags]" properly filters untagged keywords.
  2. pekkaklarck commented on Feb 25, 2026

    @pekkaklarck
    Member

    This feature sounds good and the overall design is pretty straightforward. Probably the hardest part is designing the UI.

    Do you @yanne have opinions? Do you think we could do this as part of RF 7.5? You are also better to evaluate the implementation by @mkorpela and Gemini. I personally don't have problems with accepting AI generated code, but it certainly needs to be reviewed properly.

  3. mkorpela commented on Feb 25, 2026

    @mkorpela
    Member

    @pekkaklarck @yanne just to set the expectations, I did not spent more than 5 minutes on this. But I’ll check later more.

  4. mkorpela commented on Feb 25, 2026

    @mkorpela
    Member

    @yanne pushed the AI slop to a branch. The UI would need some iteration, but something like this.. I would be happy to show you and @pekkaklarck my tool for doing stuff like this.

    https://github.com/robotframework/robotframework/tree/topic-tag-filters-poc

  5. robinmackaij commented on Mar 2, 2026

    @robinmackaij
    ContributorAuthor

    I added the library name as tag to the keywords in OpenApiTools and generated the docs using the branch above. Initial results:

    Image Image

    Remarks / observations:

    • I would suggest changing the CLI args to plural forms (showtags / hidetags).
    • The show / hide are still single-select.
    • The show / hide boxes are not dropdowns anymore. I believe they should be; if there are many keyword tags, it´d take a lot of screen estate, pushing the actual keyword links down.
    • We should decide on how to show what filters are applied (if the controls are changed to dropdowns).
    • The default labels for the controls need some consideration; I would propose <no tags selected> and <no tags hidden>.
      • Related to this, there's also special options needed to only show / hide keywords with no associated tags; <show tagless> / <hide tagless>...but then with a better word than tagless.
  6. pekkaklarck commented on Mar 3, 2026

    @pekkaklarck
    Member

    Quick comments:

    • @yanne promised to look at this in the near future.
    • Seeing @mkorpela's setup would be cool.
    • Would it make sense to add also CLI options for including/excluding keywords based on tags so that they wouldn't be shown in HTML or specs at all? It would be related to this, but should nevertheless get a separate issue. Implementation would be fully on the Python side and it probably could reuse lot of Robot's --include/--exclude machinery.
  7. self-assigned this
    on Apr 3, 2026
  8. added this to the v7.5 milestone on Apr 3, 2026
  9. modified the milestones: v7.5, v7.6 on Jul 16, 2026
  10. mardukbp commented on Oct 20, 2026

    @mardukbp

    Adding the CLI options --hidetag and --showtag to libdoc would be very useful for generating documentation for Browser library plugins. I would suggest extracting this feature to a separate issue.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions