Files
sanspie 69d19e501f Stage 7: documentation, help, playground; templates, aego new/bootstrap/icons, launcher
Documentation: engine/docs assembles one registry from the script
bindings, the schema, module docs and module-owned script paths; problems
are reported as warnings at build time. Module registries record doc
sources and script module owners; diag.Codes lists every diagnostic code.

Project bootstrap: project.defaultSpace ("2d"/"3d"), EnsureDirs creates
the default folders when the editor opens a project (reported in the
console), prefabs/ is a pipeline root. Native builds drop -trimpath so
binding locations resolve inside native/.

Editor files: create scene/prefab/script from menus, move/rename/duplicate
/delete with undo, script package retargeting on move, open scenes and
script panels follow renames, Save As / Rename Scene prompts, scene
picker, startup scene. Scoped shortcuts fall back to the global command
when disabled; Save As is Ctrl+Shift+S, Save All Ctrl+Alt+S.

Script editor: Go to Implementation (stub → native/ source), host
definitions always resolve to stubs, bracket match/mismatch states,
rainbow brackets (persisted), mono code font (ui-mono atlases, per-command
fonts in draw.List, PushFont/PopFont restored by Mark/Restore).

Tests: langsvc definition/implementation, bracket states, dispatch
fallback, script renames, font stack, editor file-op integration, golden
mono glyph and bracket references; depcheck rule for engine/docs.

Docs pipeline: engine, render2d and script/engine ship their own res/docs;
keyword hover text comes from the registry through manifest.Keywords;
project script symbols join the registry; aego docs export|check|build|
serve, --tool docs in native binaries, aego check --explain; app/docstool
and the tools/gendocs module (goldmark) build the static site.

Playground: app/playground + cmd/aego-playground (js/wasm, 3.3 MB gzip)
compile, highlight and run scripts in the browser; run blocks in the
language docs become examples. engine/builtin/headless is the module set
without render3d; workspace.Config.FS; StubFor/StubPaths; backends and the
script importer drop out of js builds.

VM: one frame pointer in the interpreter loop, direct host calls, panic
recovery once per run instead of per host call (Update2k -19%,
Schedule10k -24% against the previous head). bench-build/compare/profile
run pre-built, pinned, interleaved binaries.

Editor: structural bracket levels and current-block highlight, indent
guides, occurrence highlighting with write marks, multi-format clipboard
(copy/cut/paste assets, paste images as sprites or textures). gl33 probes
a renderable depth format and reports framebuffer failures by stage.

7 E:
- project templates empty/2d/2.5d/3d, app/projects as the single creation path (D148)
- launcher and recent projects (D149)
- orthographic Camera3D and Scene View (D150)
- reference states in the Inspector, ids.Short (D151)
- sceneio remaps node references when loading without KeepIDs (D152)
- exported ComponentRef<T> (D153)
- aego icons via module.Audit (D146)
2026-10-13 01:08:56 +03:00

151 lines
3.2 KiB
Go

package diag
import (
"go/ast"
"go/parser"
"go/token"
"io/fs"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
)
var (
codeRe = regexp.MustCompile(`AES\d{4}`)
nameRe = regexp.MustCompile(`\b(?:diag|vm)\.([A-Z]\w*)`)
)
var uncovered = map[string]string{
BadConstType: "unreachable from source: every non-constant type is rejected earlier as NotConstant or TypeMismatch",
}
func declaredCodes(t *testing.T) map[string]string {
t.Helper()
f, err := parser.ParseFile(token.NewFileSet(), "codes.go", nil, 0)
if err != nil {
t.Fatal(err)
}
out := map[string]string{}
for _, d := range f.Decls {
gd, ok := d.(*ast.GenDecl)
if !ok || gd.Tok != token.CONST {
continue
}
for _, s := range gd.Specs {
vs := s.(*ast.ValueSpec)
for i, n := range vs.Names {
if i >= len(vs.Values) {
continue
}
lit, ok := vs.Values[i].(*ast.BasicLit)
if !ok || lit.Kind != token.STRING {
continue
}
v, err := strconv.Unquote(lit.Value)
if err == nil {
out[n.Name] = v
}
}
}
}
return out
}
func TestEveryCodeHasHelp(t *testing.T) {
for name, c := range declaredCodes(t) {
if _, ok := Explain(c); !ok {
t.Errorf("%s (%s) has no explain entry", c, name)
}
}
}
func TestDocsMentionOnlyRealCodes(t *testing.T) {
known := map[string]bool{}
for _, c := range declaredCodes(t) {
known[c] = true
}
var files []string
for _, pat := range []string{"*/res/docs/*.md", "*/*/res/docs/*.md"} {
m, _ := filepath.Glob(filepath.Join("..", "..", pat))
files = append(files, m...)
}
if len(files) == 0 {
t.Fatal("docs not found")
}
files = append(files, filepath.Join("..", "..", "ARCHITECTURE.md"))
filepath.WalkDir("..", func(p string, d fs.DirEntry, err error) error {
if err == nil && !d.IsDir() && d.Name() == "doc.go" {
files = append(files, p)
}
return nil
})
for _, f := range files {
data, err := os.ReadFile(f)
if err != nil {
t.Fatal(err)
}
for _, c := range codeRe.FindAllString(string(data), -1) {
if !known[c] {
t.Errorf("%s mentions %s, which is not declared in codes.go", f, c)
}
}
}
}
func TestAllCodesHaveTest(t *testing.T) {
codes := declaredCodes(t)
seen := map[string]bool{}
walk := func(root string) {
err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
if d.Name() == "diag" {
return filepath.SkipDir
}
return nil
}
switch {
case strings.HasSuffix(p, "_test.go"), strings.HasSuffix(p, ".diag"), strings.HasSuffix(p, ".ast"):
default:
return nil
}
data, err := os.ReadFile(p)
if err != nil {
return err
}
s := string(data)
for _, c := range codeRe.FindAllString(s, -1) {
seen[c] = true
}
for _, m := range nameRe.FindAllStringSubmatch(s, -1) {
if c, ok := codes[m[1]]; ok {
seen[c] = true
}
}
return nil
})
if err != nil {
t.Fatal(err)
}
}
walk("..")
walk(filepath.Join("..", "..", "tests"))
for name, c := range codes {
if seen[c] {
if _, listed := uncovered[c]; listed {
t.Errorf("%s (%s) is tested now, remove it from the uncovered list", c, name)
}
continue
}
if _, ok := uncovered[c]; ok {
continue
}
t.Errorf("%s (%s) has no test", c, name)
}
}