From 1b7953a3c0a20dffa77e2609dd54088dea17e575 Mon Sep 17 00:00:00 2001 From: RDW Date: Mon, 17 Feb 2025 10:59:54 +0100 Subject: [PATCH 1/2] UI: Fix invisible function tables without a since tag They should still be displayed, or throw. Right now they do neither. --- src/components/API/API.jsx | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/API/API.jsx b/src/components/API/API.jsx index 6669ea7e..b3f3bd42 100644 --- a/src/components/API/API.jsx +++ b/src/components/API/API.jsx @@ -2,13 +2,30 @@ import React from "react"; import styles from "./styles.module.css"; -export const Function = ({ since, children }) => - (since && ( - <> - Available since: {since} -
{children}
- - )) || <>; +class Function extends React.Component { + render() { + const since = this.props.since; + const children = this.props.children; + const sinceBlock = (since && ( + <> + Available since: {since} + + )) || ( + <> + + Available since: ¯\_(ツ)_/¯ (Missing availability data - sorry about + that) + + + ); + return ( + <> + {sinceBlock} +
{children}
+ + ); + } +} class NilableInfo extends React.Component { render() { @@ -346,6 +363,7 @@ class Blocking extends React.Component { } export { + Function, Parameters, Parameter, Returns, From 55a5f9b36952fcee775055559398b7d658a9fb46 Mon Sep 17 00:00:00 2001 From: RDW Date: Mon, 17 Feb 2025 13:05:56 +0100 Subject: [PATCH 2/2] API: Validate Function blocks to find missing props --- src/components/API/API.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/API/API.jsx b/src/components/API/API.jsx index b3f3bd42..aab8cd95 100644 --- a/src/components/API/API.jsx +++ b/src/components/API/API.jsx @@ -6,6 +6,16 @@ class Function extends React.Component { render() { const since = this.props.since; const children = this.props.children; + + const isRunningInDevelopmentMode = process.env.NODE_ENV !== "production"; + if (isRunningInDevelopmentMode) { + // Doesn't look like more context can easily be obtained, so let's leave it at that... + const where = location; + const what = `Missing property (since) for (Function) imported from ${where}`; + const message = `${what}`; + if (!since) throw new Error(message); + } + const sinceBlock = (since && ( <> Available since: {since}