Wikipedia:Lua/Modul/WikidataScheme/Specification
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
This page describes the data structure used for a WikidataScheme specification.
A root element is to be provided.
Building blocks
[Quelltext bearbeiten]EntityName
[Quelltext bearbeiten]This can be either:
- A Wikidata entity ID, beginning with P, Q, L and followed by digits:
Q1
- A symbolic name.
- This is required to be resolved by NameResolver.
NameResolver
[Quelltext bearbeiten]This is a mapping table resolve
in root element which assigns:
- symbolic name
- mapping table as follows:
- assign a number to (at least) one of the components
P
,Q
,L
. - Basically more than one component may be present, but the first one found in that order will be used.
- assign a number to (at least) one of the components
The motivation to use a symbolic name is:
- The thematic description becomes more intuitive; described by self explaining words only.
- An entity used in several places may change pointer at once.
- The assignment may differ in development. Just apply another resolving map. Actually there are three different Wikibase installations available:
- Productive Wikidata – https://www.wikidata.org/
- WMF test Wikidata – https://test.wikidata.org/
- BETA Wikidata (wmflabs) – https://wikidata.beta.wmflabs.org/
Naturally, all expected symbolic names are to be resolved, otherwise an error is shown in displayed table.
The JSON function may be used to resolve all symbolic names and generates pretty formatted JSON with entity IDs only.
TextVariant
[Quelltext bearbeiten]This can be either:
- A string, with Wikidata entity ID only, beginning with P, Q, L and followed by digits (label will be used)
- A string, with constant text otherwise
- A mapping table, which assigns an ISO 639 / BCP47 key to a text string.
- There should be always present at least:
{ "en": "Fallback text" }
- In addition to language codes, the following two components are processed:
- class
- Sequence table (array) or string with class names for this text element
- style
- Mapping table or string with CSS for this text element
- There should be always present at least:
The resulting strings may contain balanced basic markup:
- For italic and bold,
''
and'''
wikisyntax - Internal links, with
[[w:de:double bracket]]
syntax, beginning with global project prefix. - External links, with
[http://single bracket]
syntax, beginning with protocol http https ftp. - Whitelisted HTML elements, like span div bdi bdo code pre ul ol li dl dt dd em strong b i table caption tr th td.
Entry
[Quelltext bearbeiten]This is used for both claims
and rather similar for qualifiers
.
- Sequence table, with each element as mapping table of the following (mostly optional) components:
- subject
- Property name, P-number or symbolic name resolved by NameResolver as P-number.
- Mandatory.
- intro
- General description, introduction
- TextVariant
- state
- One of:
"required"
,"suggested"
,"deprecated"
, otherwise"optional"
- values
- Sequence table (array) of mapping tables.
- Each element with the optional components in Detail.
- example
- Example value, text
- TextVariant
- terminate
- Final remarks
- TextVariant
- class
- Sequence table (array) or string with class names for entire unit
- style
- Mapping table or string with CSS for entire unit
Detail
[Quelltext bearbeiten]- One single value of statement.
- Sequence table, with each element as mapping table of the following optional components:
- intro
- q
- The one and only permitted value as item
- EntityName as Q-number.
- Must not be used together with
qlist
. - qlist
- Sequence table (array) of items, each of them:
- Item, as EntityName as Q-number.
- Last element may be
true
which indicates that other items than explicitly mentioned are permitted as well.
- Must not be used together with
q
. - qualifiers
- Permitted within
claims.values
only. - Sequence table, of Qualifier each.
- example
- terminate
Qualifier
[Quelltext bearbeiten]This is rather similar to claims
.
- One single qualifier.
- Element of a sequence table, with each element as mapping table of the following (mostly optional) components:
Root Element
[Quelltext bearbeiten]Using all definitions of building blocks, the specification is defined as follows:
- Mapping table created from the following optional components:
- caption
- Table or gadget title
- TextVariant
- onLabel
- Naming convention and expectations on label text
- TextVariant
- onDesc
- Formatting and expectations on description text
- TextVariant
- onAlias
- Formatting and expectations on aliases texts
- TextVariant
- claims
- Statements (actually mandatory)
- Sequence table of Entry
- footer
- Terminating hints, remarks, legend
- TextVariant
- id
- string, selector for entire table
- class
- Sequence table (array) or string with class names for entire table
- style
- Mapping table or string with CSS for entire table
- options
- Mapping table, override local /config
- resolve
- Mandatory if symbolic names occurring.
- NameResolver
- While all components are optional a specification without
claims
is pointless. - More components are permitted but not evaluated.
JSON and Lua
[Quelltext bearbeiten]- A mapping table in Lua is an object
{ }
in JSON. - A sequence table in Lua is an Array
[ ]
in JSON. - Both textual JSON and Lua tables may be provided.
- Lua specifications may be passed by general module call, or by providing a generating
mw.loadData()
page name. - A number of specifications may be created programmatically, e.g. fundamentals of a human being, then forking into opera singer, rock & pop musicians, composer, painter, writer, …
Example
[Quelltext bearbeiten]{ "@generated": "2024-12-08T12:51:12+01:00",
"@format": "WikidataScheme 2019-12-16",
"claims": [
{ "subject": "instance",
"state": "required",
"values": [
{
"qlist": [ "template",
"module",
"gadget",
true ]
}
]
},
{ "subject": "proglang",
"state": "suggested",
"values": [
{
"qlist": [ "lua",
"javascript",
"json",
"css" ]
}
]
},
{ "subject": "source",
"state": "suggested",
"values": [
{
"intro": "Q42253",
"qualifiers": [
{ "subject": "protocol",
"state": "required",
"q": "https"
},
{ "subject": "host",
"state": "optional",
"qlist": [ "enwiki",
"dewiki",
"mediawikiwiki",
"git",
true ]
}
]
}
]
},
{ "subject": "version",
"state": "suggested",
"values": [
{
"intro": {
"de": "Versionsbezeichnung größer als die vorangehende",
"en": "Revision ID greater than previous",
"it": "ID versione maggiore della precedente",
"ru": "Идентификатор версии выше предыдущего"
}
}
]
},
{ "subject": "licence",
"state": "suggested",
"values": [
{
"qlist": [ "Q14946043",
"Q18199165" ]
}
]
},
{ "subject": "usedby",
"state": "optional",
"values": [
{
"intro": {
"de": "Bekannte Verwendungen, oder übergeordnete Einheit",
"en": "Known usages, and root software of a sub unit",
"it": "Applicazioni note o unità supoeriore",
"ru": "Известное использование или родительская программная единица"
}
}
]
},
{ "subject": "uses",
"state": "optional",
"values": [
{
"intro": {
"de": "Abhängigkeiten, benötigte Ressourcen, aus anderen Paketen oder Untereinheiten",
"en": "Dependencies, required resources, from other packages or sub units",
"it": "Dipendenze, risorse necessarie, da altri pacchetti o da unità inferiori",
"ru": "Зависимости, требуемые ресурсы, из других пакетов или подъединиц"
}
}
]
},
{ "subject": "doc",
"state": "suggested",
"values": [
{
"intro": "Q42253",
"qualifiers": [
{ "subject": "protocol",
"state": "required",
"q": "https"
},
{ "subject": "host",
"state": "optional",
"qlist": [ "enwiki",
"dewiki",
"mediawikiwiki",
true ]
},
{ "subject": "lang",
"state": "optional",
"qlist": [ "en",
"de",
true ]
}
]
}
]
},
{ "subject": "tags",
"state": "optional",
"values": [
{
"intro": {
"de": "Tagging, Themen, Schlagwörter",
"en": "Tagging, topics, keywords",
"it": "Tag, materie, parole chiave",
"ru": "Тегинг, темы, ключевые слова"
}
}
]
}
],
"resolve": { "css": { "Q": 46441 },
"de": { "Q": 188 },
"dewiki": { "Q": 48183 },
"doc": { "P": 973 },
"en": { "Q": 1860 },
"enwiki": { "Q": 328 },
"gadget": { "Q": 61866692 },
"git": { "Q": 186055 },
"host": { "P": 137 },
"https": { "Q": 44484 },
"instance": { "P": 31 },
"javascript": { "Q": 2005 },
"json": { "Q": 2063 },
"lang": { "P": 407 },
"licCC3": { "Q": 14946043 },
"licence": { "P": 275 },
"lua": { "Q": 207316 },
"mediawikiwiki": { "Q": 15633578 },
"module": { "Q": 15184295 },
"proglang": { "P": 277 },
"protocol": { "P": 2700 },
"source": { "P": 1324 },
"tags": { "P": 366 },
"template": { "Q": 11266439 },
"usedby": { "P": 1535 },
"uses": { "P": 2283 },
"version": { "P": 348 }
}
}