Module:section article

Bonjour, vous êtes venu ici pour chercher la signification du mot Module:section article. Dans DICTIOUS, vous trouverez non seulement toutes les significations du dictionnaire pour le mot Module:section article, mais vous apprendrez également son étymologie, ses caractéristiques et comment dire Module:section article au singulier et au pluriel. Tout ce que vous devez savoir sur le mot Module:section article est ici. La définition du mot Module:section article vous aidera à être plus précis et correct lorsque vous parlerez ou écrirez vos textes. Connaître la définition deModule:section article, ainsi que celles d'autres mots, enrichit votre vocabulaire et vous fournit des ressources linguistiques plus nombreuses et de meilleure qualité.

 Documentation

Ce module définit des fonctions pour manipuler les titres de sections des articles (synonymes, étymologie, etc.) autres que les sections de langue et les sections de mots. Il utilisé essentiellement par Module:section.

La définition des sections standardisées et des alias autorisés est écrite dans Module:section article/data.

Fonctions exportées

isValidSectionType()

Indique si la valeur passée est un titre de section valide.

Paramètres
  • code (string) : La valeur à tester.
Type de retour
boolean

isSectionTypeAlias()

Indique si la valeur passée est un alias de titre de section.

Paramètres
  • code (string) : La valeur à tester.
Type de retour
boolean

getSectionTypeName()

Retourne le nom d’un titre de section ou nil s’il n’en possède pas (très certainement un bug dans ce cas).

  • code (string) : Le code de la section dont le nom doit être retourné.
Type de retour
string|nil

getSectionTypeClass()

Retourne la classe CSS d’un titre de section ou nil s’il n’en possède pas.

  • code (string) : Le code de la section dont la classe CSS doit être retournée.
Type de retour
string|nil

getSectionTypeCategoryName()

Retourne le nom de la catégorie d’un titre de section ou nil s’il n’en possède pas.

  • code (string) : Le code de la section dont le nom doit être retourné.
Type de retour
string|nil

getSectionTypePopupText()

Retourne le texte d’infobulle d’un titre de section ou nil s’il n’en possède pas. Il s’agit du texte de l’attribut title de la balise HTML du titre.

  • code (string) : Le code de la section dont le texte d’infobulle doit être retourné.
Type de retour
string|nil

local data = mw.loadData("Module:section article/data")

local p = {}

--- Get the data for the given section type code.
--- @param code string The section type code to get the data of.
--- @return table|nil A `table` containing the data for the given section type, or `nil` if the code is `nil` or `invalid`.
local function getSectionData(code)
  if code == nil then
    return nil
  end
  if p.isSectionTypeAlias(code) then
    code = data
  end
  if data then
    return data
  end
  return nil
end

--- Check whether the given value is a valid section type code from ].
--- @param code string The string to check.
--- @return boolean True if the argument is a valid section type code, false otherwise.
function p.isValidSectionType(code)
  return code and getSectionData(code)
end

--- Check whether the given value is a valid section type code alias from ].
--- @param code string The string to check.
--- @return boolean True if the argument is a valid section type code alias, false otherwise.
function p.isSectionTypeAlias(code)
  return code and data
end

--- Return the value of the given property for a specific section type.
--- @param code string The code of a section type as defined in ].
--- @param propertyName string The name of the property.
--- @return string|nil The property’s value or `nil` if it there is no data for the given code or the property is undefined.
local function getProperty(code, propertyName)
  local sectionTypeData = getSectionData(code)
  return sectionTypeData and sectionTypeData
end

--- Get the name of the given section type code.
--- @param code string The code of a section type as defined in ].
--- @return string|nil The section type’s name or `nil` if the code is `nil` or invalid.
function p.getSectionTypeName(code)
  return getProperty(code, "nom")
end

--- Get the CSS class of the given section type code.
--- @param code string The code of a section type as defined in ].
--- @return string|nil The section type’s CSS class or `nil` if the section type has none or the code is `nil` or invalid.
function p.getSectionTypeClass(code)
  return getProperty(code, "class")
end

--- Get the category name of the given section type code.
--- @param code string The code of a section type as defined in ].
--- @return string|nil The section type’s category name or `nil` if the section type has none or the code is `nil` or invalid.
function p.getSectionTypeCategoryName(code)
  return getProperty(code, "category")
end

--- Get the popup text of the given section type code.
--- @param code string The code of a section type as defined in ].
--- @return string|nil The section type’s popup text or `nil` if the section type has none or the code is `nil` or invalid.
function p.getSectionTypePopupText(code)
  return getProperty(code, "infobulle")
end

--- Return whether the given section needs a language code as its parameter.
--- @param code string The code of a section type as defined in ].
--- @return boolean True if the section requires a language code, false otherwise.
function p.sectionRequiresLanguageCode(code)
  return getProperty(code, "requiresLanguageCode")
end

return p