Skip to content

Conversation

@davepagurek
Copy link
Contributor

@davepagurek davepagurek commented Nov 12, 2025

Fixes for a few issues on the p5 site.

DEGREES and degrees() conflicts

Documentation.js parses the foundation module's properties like this, without a name field and with an error in the parsed property tag:

{
    "description": {
      "type": "root",
      // description fields omitted for brevity
    },
    "tags": [
      {
        "title": "property",
        "description": null,
        "lineNumber": 107,
        "type": null,
        "errors": [
          "Missing or invalid tag type"
        ],
        "name": "if"
      },
      {
        "title": "example",
        "description": "<div>\n<code>\n// Click the mouse to show the circle.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(mouseX, mouseY, 20);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Click the mouse to show different shapes.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(50, 50, 20);\n  } else {\n    ellipse(50, 50, 20, 50);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Move the mouse to change the background color.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A square changes color from white to black as the user moves the mouse from left to right.'\n  );\n}\n\nfunction draw() {\n  if (mouseX < 33) {\n    background(255);\n  } else if (mouseX < 67) {\n    background(200);\n  } else {\n    background(0);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle drawn on a gray background. The circle changes color to red when the user presses the \"r\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (keyIsPressed === true) {\n    if (key === 'r') {\n      fill('red');\n    }\n  }\n\n  circle(50, 50, 40);\n}\n</code>\n</div>",
        "lineNumber": 109
      }
    ],
    "loc": {
      "start": {
        "line": 110,
        "column": 0,
        "index": 2122
      },
      "end": {
        "line": 315,
        "column": 3,
        "index": 7335
      }
    },
    "context": {
      "loc": {
        "start": {
          "line": 1,
          "column": 0,
          "index": 0
        },
        "end": {
          "line": 2170,
          "column": 0,
          "index": 53199
        }
      },
      "file": "/Users/dpagurek/Documents/Projects/p5.js-2/src/core/reference.js"
    },
    "augments": [],
    "examples": [
      {
        "description": "<div>\n<code>\n// Click the mouse to show the circle.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle on a gray background. The circle follows the mouse user clicks on the canvas.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(mouseX, mouseY, 20);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Click the mouse to show different shapes.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white ellipse on a gray background. The ellipse becomes a circle when the user presses the mouse.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (mouseIsPressed === true) {\n    circle(50, 50, 20);\n  } else {\n    ellipse(50, 50, 20, 50);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Move the mouse to change the background color.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A square changes color from white to black as the user moves the mouse from left to right.'\n  );\n}\n\nfunction draw() {\n  if (mouseX < 33) {\n    background(255);\n  } else if (mouseX < 67) {\n    background(200);\n  } else {\n    background(0);\n  }\n}\n</code>\n</div>\n\n<div>\n<code>\n// Click on the canvas to begin detecting key presses.\n\nfunction setup() {\n  createCanvas(100, 100);\n\n  describe(\n    'A white circle drawn on a gray background. The circle changes color to red when the user presses the \"r\" key.'\n  );\n}\n\nfunction draw() {\n  background(200);\n\n  if (keyIsPressed === true) {\n    if (key === 'r') {\n      fill('red');\n    }\n  }\n\n  circle(50, 50, 40);\n}\n</code>\n</div>"
      }
    ],
    "implements": [],
    "params": [],
    "properties": [],
    "returns": [],
    "sees": [],
    "throws": [],
    "todos": [],
    "yields": [],
    "members": {
      "global": [],
      "inner": [],
      "instance": [],
      "events": [],
      "static": []
    },
    "path": [],
    "namespace": ""
  }

This is because it's documented as @property if, without a type, which Documentation.js doesn't like. We used to have some code to handle that but I accidentally removed it when refactoring the TS type generation, so this ensures that the Foundation section gets generated again.

p5.Vector.add not showing up in search

Search currently omits things with empty descriptions, and the p5.Vector.add method had no description because the static version of this method has no description and was overwriting the non-static one. I think the order the methods were encountered changed and recently caused the static ones to "win" here.

A better longer-term fix would be to:

  • not bin all methods together in utils/data-processor.mjs and instead to keep static ones separate so they can't overwrite each other
  • figure out a way to differentiate between static/instance methods of the same name in the reference

@ksen0 ksen0 merged commit a0fe46f into dev-2.0 Nov 12, 2025
5 of 6 checks passed
@ksen0 ksen0 deleted the fix-site branch November 12, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants