Repository navigation
Check a drawing against its standard with lint - #46
Merged
Merged
Conversation
`lint(drawing, { standard })` holds a drawing to the standard it is drawn to, as the builder
does at each call, so a drawing made by other code or read from JSON is held to it too. Without
`standard`, `lint` reports what it did before.
- `lint` takes the standard as plain data, from this copy of tsdraft or another: it checks it
and works out its hash again. A standard that does not check, or whose hash is not its
content's, is one `standard` error, and `lint` holds the drawing to nothing else of it.
`discipline` names the drawing's discipline, which resolves the entries with fields by
discipline.
- A drawing that breaks what the builder refuses gets an error under the same rule: a layer, a
linetype, a text style or a dimension style the standard does not have, an entity of model
space or of a layout on layer `0`, an entity's lineweight that is no pen's, a text in no
role's text style, a viewport at no scale of the standard, a layout on a paper that no sheet
format is on, and a second layout under `sheet-per-file`.
- And what only the whole drawing shows: a layer, a linetype, a role's text style or a dimension
style whose values are not the standard's, a layout whose plot style table is not its sheet
format's, a viewport past its drawing area or into the title block, a title block whose block,
text styles, linetypes or xref are not the standard's, a text that plots at another height
than its role's, or below the standard's least height, in a viewport that shows it or on its
layout, and a dimension shown at another ratio than its style's.
- Warnings say when a layout's sheet format cannot be told, when a layout has no title block, a
field is unset or its value runs past its box, when entries with fields by discipline went
unchecked, and where the checks of heights stopped at their limit.
- A layout's sheet format is the one on its paper. Among several on its paper, it is one whose
title block the layout inserts, and of those, one whose plot style table the layout has, so
two sheet formats that differ only in their plot style table are told apart. Sheet formats
that share a title block are checked alike.
- `lint` stays bounded on any data. It reads a list up to its first empty slot, as its other
rules do. The checks of heights enter only a block that can draw a text, and count each insert
they walk, each item of the block it enters, each name the first time they read it, by its
length, the length of each text, of what each dimension's label reads, its style's name, its
own text and its style's prefix, suffix and text style, and of each error's message. They stop
at their limit, or at blocks nested deeper than they can follow, with `standard-check-capped`.
A title block's definition with a field its kind does not have is not the standard's, and its
JSON is compared no further than the length of the standard's. Its work on the standard grows
with the standard's size, not with its dimension styles times its scales.
- `defineStandard` checks that no two names of its dimension styles, on a layout and at each
scale, are one to AutoCAD in time that grows with its styles and scales, not with their product,
and reports the same problems.
- `LintRule` gains `discipline-unknown`, `linetype-differs-from-standard`,
`text-style-differs-from-standard`, `dimension-style-differs-from-standard`,
`sheet-format-ambiguous`, `height-below-standard`, `height-off-role`, `dimension-off-scale`,
`viewport-outside-drawing-area`, `title-block-missing`, `title-block-differs-from-standard`,
`title-block-field-unset`, `title-block-field-overflow` and `standard-check-capped`. Code that
switches over every rule needs them. `LintOptions` is a type: `version` alone, or `standard`
with `version` and `discipline`. [docs/rules.md](docs/rules.md) lists each rule.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was opened by the export from tsdraft's development repository. Each commit
here is one change made there.
Merge it with squash, or with rebase to keep one commit per change. Don't push to this branch:
the next export replaces anything that did not come from it.