Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move spec org/group/status info to a config file #2908

Merged
merged 25 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6d84d63
wip
tabatkins Nov 15, 2021
9dc7a14
WIP rewrite the kdl format, start creating the manager class
tabatkins Aug 6, 2024
eca96de
Put statuses.kdl in the boilerplate folder, as it'll need to be modif…
tabatkins Aug 8, 2024
dc90285
Finish the basic formating/importing of data.
tabatkins Aug 9, 2024
75fe915
wip
tabatkins Aug 13, 2024
92e5a1f
wip
tabatkins Aug 16, 2024
68332b8
Finish updating all usage sites of the old status code.
tabatkins Aug 16, 2024
cfdc180
Fix file location
tabatkins Aug 16, 2024
b05e33e
Add test group and bs-test org. Fix nodes to all be org.
tabatkins Aug 16, 2024
6d72601
Allow type to be omitted
tabatkins Aug 16, 2024
79615e6
Grab from the right nodes
tabatkins Aug 16, 2024
ba21e9c
wip fixing errors
tabatkins Aug 17, 2024
0fe4889
Move org/group/status from MetadataManager to a new Doctype object on…
tabatkins Aug 19, 2024
3e346b6
Swap the org/group/status order around to be consistent at all callsi…
tabatkins Aug 19, 2024
eed66eb
Some bugs, and move/copy some statuses into the w3c org. Fix the test…
tabatkins Aug 19, 2024
ba5aad6
rebase tests
tabatkins Aug 19, 2024
8035e8b
Uppercase org/group/status. Fold type/groupTypes into the general Gro…
tabatkins Aug 20, 2024
173e7df
A few more little fixes, and rebase tests
tabatkins Aug 20, 2024
404079f
Add the few groups that are in boilerplates project but not present h…
tabatkins Aug 23, 2024
b1c6c06
Export Doctype in the module
tabatkins Aug 26, 2024
82948c5
Refresh spec data, so doctypes.kdl will be included by default
tabatkins Aug 26, 2024
f0b9291
Make the sources list a little less stupid (no Nones or strings conta…
tabatkins Aug 26, 2024
2337f2c
refresh data again
tabatkins Aug 26, 2024
295f26b
Rebase manual tests
tabatkins Aug 26, 2024
6426c73
Rebase non-manual tests. Not reviewed; they're just data changes. Thi…
tabatkins Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 18 additions & 6 deletions bikeshed/Spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
constants,
datablocks,
dfns,
doctypes,
extensions,
fingerprinting,
h,
Expand Down Expand Up @@ -108,6 +109,7 @@ def initializeState(self) -> bool:
self.widl: widlparser.Parser = idl.getParser()

self.languages: dict[str, language.Language] = fetchLanguages(self.dataFile)
self.doctypes: doctypes.DoctypeManager = fetchDoctypes(self.dataFile)

self.extraJC = stylescript.JCManager()
self.extraJC.addColors()
Expand Down Expand Up @@ -141,21 +143,27 @@ def initMetadata(self, inputContent: InputSource.InputContent) -> None:
# in a markdown code span or an <xmp> to show off.
_, self.mdDocument = metadata.parse(lines=inputContent.lines)

# Combine the data so far...
# Combine the data so far, and compute the doctype
# (the other md sources need the doctype in order to be found)
self.md = metadata.join(self.mdBaseline, self.mdDocument, self.mdCommandLine)
rawDoctype = (self.md.rawOrg, self.md.rawGroup, self.md.rawStatus)
self.doctype = self.doctypes.getDoctype(self.md.rawOrg, self.md.rawGroup, self.md.rawStatus)

# Using that to determine the Group and Status, load the correct defaults.include boilerplate
self.mdDefaults = metadata.fromJson(
data=retrieve.retrieveBoilerplateFile(self, "defaults", error=True),
data=retrieve.retrieveBoilerplateFile(self, "defaults"),
source="defaults",
)
self.md = metadata.join(self.mdBaseline, self.mdDefaults, self.mdDocument, self.mdCommandLine)
if rawDoctype != (self.md.rawOrg, self.md.rawGroup, self.md.rawStatus):
# recompute doctype
self.doctype = self.doctypes.getDoctype(self.md.rawOrg, self.md.rawGroup, self.md.rawStatus)

# Using all of that, load up the text macros so I can sub them into the computed-metadata file.
self.md.fillTextMacros(self.macros, doc=self)
jsonEscapedMacros = {k: json.dumps(v)[1:-1] for k, v in self.macros.items()}

computedMdText = h.replaceMacrosTextly(
retrieve.retrieveBoilerplateFile(self, "computed-metadata", error=True),
retrieve.retrieveBoilerplateFile(self, "computed-metadata"),
macros=jsonEscapedMacros,
context="? of computed-metadata.include",
)
Expand All @@ -173,7 +181,7 @@ def initMetadata(self, inputContent: InputSource.InputContent) -> None:
# And compute macros again, in case the preceding steps changed them.
self.md.fillTextMacros(self.macros, doc=self)

self.md.validate()
self.md.validate(doc=self)
m.retroactivelyCheckErrorLevel()

def earlyParse(self, inputContent: InputSource.InputContent) -> list[l.Line]:
Expand Down Expand Up @@ -231,7 +239,7 @@ def assembleDocument(self) -> Spec:
features=markdownFeatures,
)

self.refs.setSpecData(self.md)
self.refs.setSpecData(self)

# Convert to a single string of html now, for convenience.
self.html = "".join(x.text for x in self.lines)
Expand Down Expand Up @@ -554,6 +562,10 @@ def fetchLanguages(dataFile: retrieve.DataFileRequester) -> dict[str, language.L
}


def fetchDoctypes(dataFile: retrieve.DataFileRequester) -> doctypes.DoctypeManager:
return doctypes.DoctypeManager.fromKdlStr(dataFile.fetch("boilerplate", "doctypes.kdl", str=True))


def addDomintroStyles(doc: Spec) -> None:
# Adds common WHATWG styles for domintro blocks.

Expand Down
6 changes: 3 additions & 3 deletions bikeshed/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def getFillContainer(tag: str, doc: t.SpecT, default: bool = False) -> t.Element

# Otherwise, append to the end of the document,
# unless you're in the byos group
if doc.md.group == "byos":
if doc.doctype.group.name == "BYOS":
return None
if default:
return doc.body
Expand Down Expand Up @@ -240,7 +240,7 @@ def removeUnwantedBoilerplate(doc: t.SpecT) -> None:


def w3cStylesheetInUse(doc: t.SpecT) -> bool:
return doc.md.prepTR or doc.md.status in config.snapshotStatuses
return doc.md.prepTR or doc.doctype.group.name == "W3C"


def addBikeshedBoilerplate(doc: t.SpecT) -> None:
Expand Down Expand Up @@ -933,7 +933,7 @@ def printPreviousVersion(v: dict[str, str]) -> t.ElementT | None:
md.setdefault("This version", []).append(h.E.a({"href": mac["version"], "class": "u-url"}, mac["version"]))
if doc.md.TR:
md.setdefault("Latest published version", []).append(h.E.a({"href": doc.md.TR}, doc.md.TR))
if doc.md.ED and doc.md.status in config.snapshotStatuses:
if doc.md.ED and "TR" in doc.doctype.status.requires:
md.setdefault("Editor's Draft", []).append(h.E.a({"href": doc.md.ED}, doc.md.ED))
if doc.md.previousVersions:
md["Previous Versions"] = [printPreviousVersion(ver) for ver in doc.md.previousVersions]
Expand Down
4 changes: 2 additions & 2 deletions bikeshed/conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses
import re

from . import config, h, t
from . import h, t
from . import messages as m

# Any element can have an include-if or exclude-if attribute,
Expand Down Expand Up @@ -61,7 +61,7 @@ def processConditionals(doc: t.SpecT, container: t.ElementT | None = None) -> No
def evalConditions(doc: t.SpecT, el: t.ElementT, conditionString: str) -> t.Generator[bool, None, None]:
for cond in parseConditions(conditionString, el):
if cond.type == "status":
yield config.looselyMatch(cond.value, doc.md.status)
yield doc.doctype.status.looselyMatch(cond.value)
elif cond.type == "text macro":
for k in doc.macros:
if k.upper() == cond.value:
Expand Down
20 changes: 0 additions & 20 deletions bikeshed/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,3 @@
simplifyText,
splitForValues,
)
from .status import (
canonicalizeStatus,
datedStatuses,
deadlineStatuses,
implementationStatuses,
looselyMatch,
megaGroups,
noEDStatuses,
shortToLongStatus,
snapshotStatuses,
splitStatus,
unlevelledStatuses,
w3cCgs,
w3cCommunityStatuses,
w3cIgs,
w3cIGStatuses,
w3cProcessDocumentStatuses,
w3cTAGStatuses,
w3cWGStatuses,
)
1 change: 1 addition & 0 deletions bikeshed/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
def englishFromList(items: t.Iterable[str], conjunction: str = "or") -> str:
# Format a list of strings into an English list.
items = list(items)
assert len(items) > 0
if len(items) == 1:
return items[0]
if len(items) == 2:
Expand Down
Loading
Loading