@eagleoutice/flowr 2.14.3 → 2.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,21 +79,6 @@ export declare function statedSignatures(definitions?: BuiltInDefinitions): Map<
79
79
  * R's, else whichever came first. `undefined` when flowR states nothing about the name at all.
80
80
  */
81
81
  export declare function statedSignatureOf(stated: ReadonlyMap<string, readonly StatedSignature[]>, name: string, pkg?: string): StatedSignature | undefined;
82
- /**
83
- * R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
84
- * `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
85
- * `Ops` is what S3 calls the union of the three S4 groups it splits into.
86
- */
87
- export declare const RGroupGenerics: {
88
- readonly Arith: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%"];
89
- readonly Compare: readonly ["==", "!=", "<", "<=", ">", ">="];
90
- readonly Logic: readonly ["&", "|"];
91
- readonly Ops: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%", "==", "!=", "<", "<=", ">", ">=", "&", "|", "!"];
92
- readonly Math: readonly ["abs", "sign", "sqrt", "floor", "ceiling", "trunc", "exp", "expm1", "log", "log2", "log10", "log1p", "cos", "sin", "tan", "cosh", "sinh", "tanh", "acos", "asin", "atan", "acosh", "asinh", "atanh", "cumsum", "cumprod", "cummax", "cummin"];
93
- readonly Math2: readonly ["round", "signif"];
94
- readonly Summary: readonly ["any", "sum", "prod", "min", "max", "range"];
95
- readonly Complex: readonly ["Re", "Im", "Mod", "Arg", "Conj"];
96
- };
97
82
  /**
98
83
  * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
99
84
  * is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.RGroupGenerics = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
3
+ exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
4
4
  exports.namespacePlotFunctions = namespacePlotFunctions;
5
5
  exports.statedSignatures = statedSignatures;
6
6
  exports.statedSignatureOf = statedSignatureOf;
@@ -269,24 +269,6 @@ const LinkToLastPlot = {
269
269
  type: 'link-to-last-call',
270
270
  callName: toRegex(GraphicDeviceOpen.concat(exports.PlotCreate, PlotAddons, exports.GgPlotAddons, exports.TinyPlotAddons))
271
271
  };
272
- const Arith = ['+', '-', '*', '/', '^', '**', '%%', '%/%'];
273
- const Compare = ['==', '!=', '<', '<=', '>', '>='];
274
- const Logic = ['&', '|'];
275
- /**
276
- * R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
277
- * `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
278
- * `Ops` is what S3 calls the union of the three S4 groups it splits into.
279
- */
280
- exports.RGroupGenerics = {
281
- Arith, Compare, Logic,
282
- Ops: [...Arith, ...Compare, ...Logic, '!'],
283
- Math: ['abs', 'sign', 'sqrt', 'floor', 'ceiling', 'trunc', 'exp', 'expm1', 'log', 'log2', 'log10', 'log1p',
284
- 'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh',
285
- 'cumsum', 'cumprod', 'cummax', 'cummin'],
286
- Math2: ['round', 'signif'],
287
- Summary: ['any', 'sum', 'prod', 'min', 'max', 'range'],
288
- Complex: ['Re', 'Im', 'Mod', 'Arg', 'Conj']
289
- };
290
272
  /**
291
273
  * The internal generics: they dispatch in C rather than through `UseMethod`, so no signature can state it and
292
274
  * the list has to be written down. Everything that dispatches from R is generated, see {@link RBasePackageStore}.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * R's group generics, kept apart from the builtin configuration so anything may ask about them without pulling
3
+ * the whole dataflow setup in (the signature database does, and that would be a cycle).
4
+ */
5
+ /**
6
+ * R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
7
+ * `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
8
+ * `Ops` is what S3 calls the union of the three S4 groups it splits into.
9
+ */
10
+ export declare const RGroupGenerics: {
11
+ readonly Arith: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%"];
12
+ readonly Compare: readonly ["==", "!=", "<", "<=", ">", ">="];
13
+ readonly Logic: readonly ["&", "|"];
14
+ readonly Ops: readonly ["+", "-", "*", "/", "^", "**", "%%", "%/%", "==", "!=", "<", "<=", ">", ">=", "&", "|", "!"];
15
+ readonly Math: readonly ["abs", "sign", "sqrt", "floor", "ceiling", "trunc", "exp", "expm1", "log", "log2", "log10", "log1p", "cos", "sin", "tan", "cosh", "sinh", "tanh", "acos", "asin", "atan", "acosh", "asinh", "atanh", "cumsum", "cumprod", "cummax", "cummin"];
16
+ readonly Math2: readonly ["round", "signif"];
17
+ readonly Summary: readonly ["any", "sum", "prod", "min", "max", "range"];
18
+ readonly Complex: readonly ["Re", "Im", "Mod", "Arg", "Conj"];
19
+ };
20
+ /**
21
+ * Member name to its S4 group (`sin` to `Math`, `+` to `Arith`). `Ops` is left out so `+` answers `Arith`
22
+ * rather than both. A package exporting such a name usually does so because it registered a method for one of
23
+ * its classes, so the name says far less about the package than an ordinary export would.
24
+ */
25
+ export declare const S4GroupOfMember: ReadonlyMap<string, string>;
26
+ /** The S4 group generic `name` is a member of, `undefined` for a name that is in none. */
27
+ export declare function groupGenericOf(name: string): string | undefined;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * R's group generics, kept apart from the builtin configuration so anything may ask about them without pulling
4
+ * the whole dataflow setup in (the signature database does, and that would be a cycle).
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.S4GroupOfMember = exports.RGroupGenerics = void 0;
8
+ exports.groupGenericOf = groupGenericOf;
9
+ const Arith = ['+', '-', '*', '/', '^', '**', '%%', '%/%'];
10
+ const Compare = ['==', '!=', '<', '<=', '>', '>='];
11
+ const Logic = ['&', '|'];
12
+ /**
13
+ * R's group generics: a class claims every member of a group at once, with an `Ops.cls` (S3) or a
14
+ * `setMethod('Arith', ...)` (S4), so a call to any member may dispatch to a method named after the group.
15
+ * `Ops` is what S3 calls the union of the three S4 groups it splits into.
16
+ */
17
+ exports.RGroupGenerics = {
18
+ Arith, Compare, Logic,
19
+ Ops: [...Arith, ...Compare, ...Logic, '!'],
20
+ Math: ['abs', 'sign', 'sqrt', 'floor', 'ceiling', 'trunc', 'exp', 'expm1', 'log', 'log2', 'log10', 'log1p',
21
+ 'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh',
22
+ 'cumsum', 'cumprod', 'cummax', 'cummin'],
23
+ Math2: ['round', 'signif'],
24
+ Summary: ['any', 'sum', 'prod', 'min', 'max', 'range'],
25
+ Complex: ['Re', 'Im', 'Mod', 'Arg', 'Conj']
26
+ };
27
+ /** the S4 groups, i.e. {@link RGroupGenerics} without `Ops`, which only S3 knows */
28
+ const S4Groups = ['Arith', 'Compare', 'Logic', 'Math', 'Math2', 'Summary', 'Complex'];
29
+ /**
30
+ * Member name to its S4 group (`sin` to `Math`, `+` to `Arith`). `Ops` is left out so `+` answers `Arith`
31
+ * rather than both. A package exporting such a name usually does so because it registered a method for one of
32
+ * its classes, so the name says far less about the package than an ordinary export would.
33
+ */
34
+ exports.S4GroupOfMember = new Map(S4Groups.flatMap(group => exports.RGroupGenerics[group].map(member => [member, group])));
35
+ /** The S4 group generic `name` is a member of, `undefined` for a name that is in none. */
36
+ function groupGenericOf(name) {
37
+ return exports.S4GroupOfMember.get(name);
38
+ }
39
+ //# sourceMappingURL=group-generics.js.map
@@ -248,10 +248,15 @@ Per version the source also answers declared dependencies (${ctx.link('ResolvedD
248
248
 
249
249
  Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.linkE('FnProp', 'NoDoc')} (a documented package has no help page for this name), ${ctx.linkE('FnProp', 'S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.linkE('FnProp', 'S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call, e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
250
250
 
251
+ The S4 side has ${ctx.linkE('FnProp', 'S4Owner')} for an exported class and ${ctx.linkE('FnProp', 'S4Method')} for a name a package exports because it answered a generic for one of its classes (\`setMethod("sin", "float32", ...)\` plus \`exportMethods(sin)\`), rather than because it defines a function of its own. Such a name is often documented only under its \`sin,float32-method\` Rd alias, so it also carries ${ctx.linkE('FnProp', 'NoDoc')}. Because \`setMethod("Math", ...)\` answers every member of a group at once, ${ctx.link('SignatureDb::functionOf')} falls back to the group entry for a member it finds nothing for: \`pkg::sin\` is served by \`pkg\`'s \`Math\`, which is what the call would dispatch to. ${ctx.link('groupGenericOf')} maps a member to its group.
252
+
253
+ ${ctx.linkE('FnProp', 'Value')} says the export binds a value rather than a function (\`pi\`, \`LETTERS\`, ggplot2's \`class_gg\`). Only the extractor can tell: an entry without a definition location is as likely to be a function nothing wrote down, an S4 generic \`setGeneric\` builds or a \`Vectorize\` result, so a reader that has only the location to go on can say no more than that there is none.
254
+
251
255
  These are derived on demand by the ${ctx.linkPage('wiki/Query API', 'signature query')}, not stored:
252
- - the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.linkE('FnProp', 'NoDoc')} function
256
+ - the documentation link ${ctx.link('SignatureFunctionView::docUrl')}, omitted for a ${ctx.linkE('FnProp', 'NoDoc')} function: R's own manual for a base package, rdrr.io's \`/cran/<pkg>/man/<topic>\` for CRAN. rdrr.io serves an older R, so everything R has gained since (\`sort_by\`, \`array2DF\`, ...) is a dead link there
253
257
  - ${ctx.link('SignatureFunctionView::sourceUrl')} and ${ctx.link('SignatureFunctionView::manUrl')}: the definition and its \`.Rd\` help page at the queried version, on \`github.com/cran/<pkg>\` (CRAN) or \`github.com/wch/r-source\` (base R)
254
258
  - the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.linkE('FnProp', 'S3Method')} function, resolving its generic
259
+ - the S4 group ${ctx.link('SignatureFunctionView::s4group')}, for a name that is a member of one (\`sin\` of \`Math\`), saying whether the view was answered by the package's entry for the group rather than by one for the name itself
255
260
  - the transitive call graph ${ctx.linkM(reader_1.SigDatabase, 'transitiveCallees')}, expanding the stored local callees inside one version
256
261
 
257
262
  ## Reading It From an Analyzer
@@ -15,7 +15,7 @@ const identifier_1 = require("../../dataflow/environments/identifier");
15
15
  const retriever_1 = require("../../r-bridge/retriever");
16
16
  const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
17
17
  const built_in_props_1 = require("../../dataflow/environments/built-in-props");
18
- const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
18
+ const group_generics_1 = require("../../dataflow/environments/group-generics");
19
19
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
20
20
  const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
21
21
  const graph_1 = require("../../dataflow/graph/graph");
@@ -37,13 +37,13 @@ let knownS3Generics;
37
37
  * (`print(x)` on an object of that class), so it is used without a textual call.
38
38
  */
39
39
  function isKnownS3Generic(name) {
40
- knownS3Generics ??= new Set([...OtherKnownS3Generics, ...Object.keys(default_builtin_config_1.RGroupGenerics),
40
+ knownS3Generics ??= new Set([...OtherKnownS3Generics, ...Object.keys(group_generics_1.RGroupGenerics),
41
41
  ...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.CallProp.Generic).map(g => identifier_1.Identifier.getName(g))]);
42
42
  return knownS3Generics.has(name);
43
43
  }
44
44
  /** Whether `generic`, or any member of it when it is a group generic (`Ops.cls` dispatches on `+`), is called. */
45
45
  function isDispatched(generic, called) {
46
- const group = default_builtin_config_1.RGroupGenerics[generic];
46
+ const group = group_generics_1.RGroupGenerics[generic];
47
47
  return called.has(generic) || (group?.some(member => called.has(member)) ?? false);
48
48
  }
49
49
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.14.3",
3
+ "version": "2.14.4",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -63,7 +63,19 @@ export declare const enum FnProp {
63
63
  * Set on the name of an S4 class this package OWNS: it exports the class via its NAMESPACE `exportClasses()`
64
64
  * (see {@link LibraryExports.s4Classes}, derived from this bit by {@link deriveLibraryExports}).
65
65
  */
66
- S4Owner = 2048
66
+ S4Owner = 2048,
67
+ /**
68
+ * A registered S4 method: the name is exported because the package answers a generic for one of its classes
69
+ * (`setMethod('sin', 'float32', ...)`, `exportMethods(sin)`), not because it defines a function of its own.
70
+ * The S4 analogue of {@link FnProp.S3Method}.
71
+ */
72
+ S4Method = 4096,
73
+ /**
74
+ * The export binds a value rather than a function: a constant, a dataset, a class object (`pi`, `LETTERS`,
75
+ * ggplot2's `class_gg`). Only the extractor can tell: an entry without a definition location may equally be
76
+ * a function built at load time, an S4 generic or a `Vectorize` result, which has no source to point at.
77
+ */
78
+ Value = 8192
67
79
  }
68
80
  /** the {@link FnProp} bit to its name (for decoding); integer keys iterate in ascending bit order */
69
81
  export declare const FnPropNames: Readonly<Record<FnProp, string>>;
@@ -30,7 +30,9 @@ exports.FnPropNames = {
30
30
  [256 /* FnProp.NoDoc */]: 'no-doc',
31
31
  [512 /* FnProp.S3Method */]: 's3-method',
32
32
  [1024 /* FnProp.S3Owner */]: 's3-owner',
33
- [2048 /* FnProp.S4Owner */]: 's4-owner'
33
+ [2048 /* FnProp.S4Owner */]: 's4-owner',
34
+ [4096 /* FnProp.S4Method */]: 's4-method',
35
+ [8192 /* FnProp.Value */]: 'value'
34
36
  };
35
37
  /** the {@link DepType} values in order, with their names (for decoding) */
36
38
  exports.DepTypeNames = ['depends', 'imports', 'linkingTo', 'suggests', 'enhances'];
@@ -40,6 +40,10 @@ export interface SignatureDb {
40
40
  /**
41
41
  * The database entry for a *qualified* call, i.e. a `pkg::fn` {@link Identifier}. Decodes only that one
42
42
  * function rather than the whole package.
43
+ *
44
+ * A name the package answers only as part of an S4 group falls back to the group: `Matrix::sin` is served by
45
+ * `Matrix`'s `Math` entry when there is no `sin` of its own, because that is what an `sin(x)` call dispatches
46
+ * to. The result then carries the group's name, not the one that was asked for.
43
47
  * @param id - The qualified identifier of the function.
44
48
  * @param version - The version to answer for, {@link versionOf} of its package if omitted.
45
49
  */
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.signatureDbOf = signatureDbOf;
4
4
  const identifier_1 = require("../../dataflow/environments/identifier");
5
+ const group_generics_1 = require("../../dataflow/environments/group-generics");
5
6
  const reader_1 = require("./reader");
6
7
  const log_1 = require("../../util/log");
7
8
  const signatureDbLog = log_1.log.getSubLogger({ name: 'signature-db' });
@@ -38,7 +39,13 @@ function signatureDbOf(deps) {
38
39
  return undefined; // without a package there is nothing to look the function up in
39
40
  }
40
41
  const name = identifier_1.Identifier.getName(id);
41
- return answerFor(pkg, version, (src, v) => src.functionByName(pkg, name, v));
42
+ const found = answerFor(pkg, version, (src, v) => src.functionByName(pkg, name, v));
43
+ if (found !== undefined) {
44
+ return found;
45
+ }
46
+ /* `setMethod('Math', 'cls', ...)` answers every member of the group at once, so the group is the entry */
47
+ const group = (0, group_generics_1.groupGenericOf)(name);
48
+ return group === undefined ? undefined : answerFor(pkg, version, (src, v) => src.functionByName(pkg, group, v));
42
49
  };
43
50
  return {
44
51
  available: () => deps.signatureSources().length > 0,
@@ -348,7 +348,7 @@ exports.GuessDepVersionsQueryDefinition = {
348
348
  const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${truncatedList(params)}]` : undefined,
349
349
  at ? `at ${at}` : undefined].filter(Boolean).join(', ');
350
350
  const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
351
- const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
351
+ const url = (0, signature_query_executor_1.helpPageUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
352
352
  const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
353
353
  const redundant = !(geVer !== undefined && geVer === tightestGe) && !(leVer !== undefined && leVer === tightestLe);
354
354
  return { bounds: [ge, le].filter(Boolean).join(' '), label, redundant, geVer, leVer };
@@ -15,8 +15,13 @@ export declare function cranMirrorSourceUrl(pkg: string, version: string | undef
15
15
  export declare function rSourceRef(version: string | undefined): string;
16
16
  /** deep-link a base-R definition into the R sources mirror at the release series of `version` */
17
17
  export declare function rSourceUrl(pkg: string, version: string | undefined, file: string, line?: number): string;
18
- /** best-effort rdrr.io documentation link: `/r/<pkg>/<fn>` for base R, `/cran/<pkg>/man/<fn>` for CRAN */
19
- export declare function rdrrDocUrl(pkg: string, fn: string, opts: {
18
+ /**
19
+ * Best-effort documentation link: R's own manual for a base package, rdrr.io's `/cran/<pkg>/man/<fn>` for CRAN.
20
+ *
21
+ * Base R does not go to rdrr.io because that serves an older release, so everything R has gained since (`sort_by`,
22
+ * `array2DF`, `chooseOpsMethod`, ...) is a dead link there.
23
+ */
24
+ export declare function helpPageUrl(pkg: string, fn: string, opts: {
20
25
  base: boolean;
21
26
  cran: boolean;
22
27
  }): string | undefined;
@@ -4,7 +4,7 @@ exports.cranPageUrl = cranPageUrl;
4
4
  exports.cranMirrorSourceUrl = cranMirrorSourceUrl;
5
5
  exports.rSourceRef = rSourceRef;
6
6
  exports.rSourceUrl = rSourceUrl;
7
- exports.rdrrDocUrl = rdrrDocUrl;
7
+ exports.helpPageUrl = helpPageUrl;
8
8
  exports.signatureFunctionInfo = signatureFunctionInfo;
9
9
  exports.signaturePackageInfo = signaturePackageInfo;
10
10
  exports.signatureQueryCompleter = signatureQueryCompleter;
@@ -22,6 +22,7 @@ const r_version_1 = require("../../../util/r-version");
22
22
  const r_base_packages_1 = require("../../../util/r-base-packages");
23
23
  const mermaid_1 = require("../../../util/mermaid/mermaid");
24
24
  const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
25
+ const group_generics_1 = require("../../../dataflow/environments/group-generics");
25
26
  const arrays_1 = require("../../../util/collections/arrays");
26
27
  /** the CRAN package landing page (only meaningful for CRAN packages, not base R) */
27
28
  function cranPageUrl(pkg) {
@@ -125,13 +126,18 @@ function rSourceUrl(pkg, version, file, line) {
125
126
  }
126
127
  /** function/topic names that map cleanly to a man page (skip operators like `+.gg`, `[.data.frame`; Rd topics allow hyphens, e.g. `dplyr-package`) */
127
128
  const RdrrTopicName = /^[A-Za-z.][A-Za-z0-9._-]*$/;
128
- /** best-effort rdrr.io documentation link: `/r/<pkg>/<fn>` for base R, `/cran/<pkg>/man/<fn>` for CRAN */
129
- function rdrrDocUrl(pkg, fn, opts) {
129
+ /**
130
+ * Best-effort documentation link: R's own manual for a base package, rdrr.io's `/cran/<pkg>/man/<fn>` for CRAN.
131
+ *
132
+ * Base R does not go to rdrr.io because that serves an older release, so everything R has gained since (`sort_by`,
133
+ * `array2DF`, `chooseOpsMethod`, ...) is a dead link there.
134
+ */
135
+ function helpPageUrl(pkg, fn, opts) {
130
136
  if (!RdrrTopicName.test(fn)) {
131
137
  return undefined;
132
138
  }
133
139
  if (opts.base) {
134
- return `https://rdrr.io/r/${pkg}/${fn}.html`;
140
+ return `https://stat.ethz.ch/R-manual/R-devel/library/${pkg}/html/${fn}.html`;
135
141
  }
136
142
  if (opts.cran) {
137
143
  return `https://rdrr.io/cran/${pkg}/man/${fn}.html`;
@@ -140,7 +146,7 @@ function rdrrDocUrl(pkg, fn, opts) {
140
146
  }
141
147
  /**
142
148
  * The `.Rd` help source of a topic *at the queried version*, on the same mirrors the source links use. rdrr.io only
143
- * serves a package's current release, so {@link rdrrDocUrl} silently answers for the wrong version whenever an older
149
+ * serves a package's current release, so {@link helpPageUrl} silently answers for the wrong version whenever an older
144
150
  * one was asked for; this link cannot drift.
145
151
  */
146
152
  function manPageUrl(pkg, topic, version, opts) {
@@ -158,7 +164,7 @@ function docUrlsFor(pkg, fn, version, base, cran) {
158
164
  return {};
159
165
  }
160
166
  const topic = fn.topic ?? fn.name;
161
- const doc = rdrrDocUrl(pkg, topic, { base, cran });
167
+ const doc = helpPageUrl(pkg, topic, { base, cran });
162
168
  const man = manPageUrl(pkg, topic, version, { base, cran });
163
169
  return { ...(doc ? { docUrl: doc } : {}), ...(man ? { manUrl: man } : {}) };
164
170
  }
@@ -230,6 +236,7 @@ function flowrOnlyFunctionInfo(env, pkg, name) {
230
236
  if (info === undefined || (info.props === undefined && info.sig === undefined)) {
231
237
  return undefined;
232
238
  }
239
+ const group = (0, group_generics_1.groupGenericOf)(name);
233
240
  const namespace = definition.name === undefined ? undefined : identifier_1.Identifier.getNamespace(definition.name);
234
241
  if (pkg !== undefined && namespace !== undefined && namespace !== pkg) {
235
242
  return undefined;
@@ -243,7 +250,8 @@ function flowrOnlyFunctionInfo(env, pkg, name) {
243
250
  /* flowR states no defaults, so `required` stays `false` throughout; whether R forces a parameter it does know */
244
251
  parameters: (info.sig ?? []).map(([n, p]) => ({ name: n, required: false, forced: (p & built_in_props_1.ArgProp.Forced) !== 0 })),
245
252
  callees: [],
246
- flowr: flowrViewOf(info, [])
253
+ flowr: flowrViewOf(info, []),
254
+ ...(group ? { s4group: { group } } : {})
247
255
  };
248
256
  }
249
257
  /** the decoded view of one function, adding the CRAN-mirror source link */
@@ -272,7 +280,11 @@ function decodedToView(pkg, fn, version, opts) {
272
280
  */
273
281
  function signatureFunctionInfo(src, pkg, fnName, version, env) {
274
282
  const fns = src.functions(pkg, version) ?? src.functions(pkg);
275
- const fn = fns?.find(f => f.name === fnName);
283
+ const group = (0, group_generics_1.groupGenericOf)(fnName);
284
+ const own = fns?.find(f => f.name === fnName);
285
+ /* `setMethod('Math', 'cls', ...)` answers every member of the group at once, so the group entry is what a
286
+ call to a member it has none of its own for dispatches to */
287
+ const fn = own ?? (group === undefined ? undefined : fns?.find(f => f.name === group));
276
288
  if (fn === undefined) {
277
289
  return undefined;
278
290
  }
@@ -288,9 +300,12 @@ function signatureFunctionInfo(src, pkg, fnName, version, env) {
288
300
  const flowr = flowrView(env, pkg, fnName, view.parameters.map(p => p.name));
289
301
  return {
290
302
  ...view,
303
+ /* the name that was asked for, which is not the entry's own when the group answered for it */
304
+ name: fnName,
291
305
  ...(flowr ? { flowr } : {}),
292
306
  ...(methods.length > 0 ? { s3generic: true, s3methods: methods } : {}),
293
- ...(s3method ? { s3method } : {})
307
+ ...(s3method ? { s3method } : {}),
308
+ ...(group ? { s4group: { group, ...(own === undefined ? { viaGroup: true } : {}) } } : {})
294
309
  };
295
310
  }
296
311
  /** whether `fn` is an S3 generic: its body dispatches via `UseMethod`, so `<name>.<class>` functions can be its methods */
@@ -51,9 +51,9 @@ export interface SignatureFunctionView {
51
51
  readonly line?: number;
52
52
  /** deep link to the definition on the read-only GitHub mirror of the sources (CRAN, or R's own for a base package) */
53
53
  readonly sourceUrl?: string;
54
- /** best-effort rdrr.io documentation link, when the function name maps to a documentable topic */
54
+ /** best-effort documentation link (R's own manual for base R, rdrr.io for CRAN), when the name maps to a documentable topic */
55
55
  readonly docUrl?: string;
56
- /** link to the `.Rd` help source *at the queried version*, which {@link docUrl} cannot offer (rdrr.io only serves the current release) */
56
+ /** link to the `.Rd` help source *at the queried version*, which {@link docUrl} cannot offer (it serves the current release alone) */
57
57
  readonly manUrl?: string;
58
58
  /** whether the function looks like an S3 generic (has `<generic>.<class>` dispatch targets in the same package) */
59
59
  readonly s3generic?: boolean;
@@ -65,6 +65,17 @@ export interface SignatureFunctionView {
65
65
  readonly class: string;
66
66
  readonly package: string;
67
67
  };
68
+ /**
69
+ * The S4 group generic the name belongs to (`sin` is in `Math`, `+` in `Arith`). `viaGroup` says the view was
70
+ * answered by the package's entry for the group rather than by one for the name itself: a
71
+ * `setMethod('Math', 'cls', ...)` answers every member of the group at once, and that is what a `sin(x)` call
72
+ * on such a class dispatches to. A member is often documented only under its `sin,cls-method` Rd alias, which
73
+ * is why such a name can carry `no-doc` and still have a help page.
74
+ */
75
+ readonly s4group?: {
76
+ readonly group: string;
77
+ readonly viaGroup?: boolean;
78
+ };
68
79
  /** a mermaid.live link visualizing the transitive call graph from this function (only when requested with `--cg`) */
69
80
  readonly callGraph?: string;
70
81
  /** what flowR itself states about the function, from the built-in environment of the analysis */
@@ -140,7 +151,7 @@ export interface SignatureMatchView {
140
151
  readonly file?: string;
141
152
  readonly line?: number;
142
153
  readonly sourceUrl?: string;
143
- /** best-effort rdrr.io documentation link, when the function name maps to a documentable topic */
154
+ /** best-effort documentation link, see {@link SignatureFunctionView.docUrl} */
144
155
  readonly docUrl?: string;
145
156
  /** link to the `.Rd` help source at the queried version, see {@link SignatureFunctionView.manUrl} */
146
157
  readonly manUrl?: string;
@@ -86,6 +86,12 @@ function pushFunction(result, f, fn) {
86
86
  if (fn.s3method) {
87
87
  result.push(` ╰ ${(0, ansi_1.italic)('S3 method of', f)} ${(0, ansi_1.color)(`${fn.s3method.package}::${fn.s3method.generic}`, 5 /* Colors.Magenta */, f)} ${(0, ansi_1.italic)(`(class ${fn.s3method.class})`, f)}`);
88
88
  }
89
+ if (fn.s4group) {
90
+ const said = fn.s4group.viaGroup
91
+ ? `answered by ${fn.package}::${fn.s4group.group}, which covers the whole group`
92
+ : `a package may answer it for its own class with setMethod('${fn.s4group.group}', ...)`;
93
+ result.push(` ╰ ${(0, ansi_1.italic)('S4 group', f)} ${(0, ansi_1.color)(fn.s4group.group, 5 /* Colors.Magenta */, f)} ${(0, ansi_1.italic)(`(${said})`, f)}`);
94
+ }
89
95
  if (fn.flowr) {
90
96
  const args = (fn.flowr.args ?? []).map(a => `${a.name}${a.roles.length > 0 ? `: ${a.roles.join('+')}` : ''}`);
91
97
  const props = fn.flowr.props.map(p => (0, ansi_1.color)(p, 4 /* Colors.Blue */, f)).join(', ');
@@ -6,8 +6,14 @@ exports.rankName = rankName;
6
6
  * conditions, so a rule can be read, weighed against its neighbours, or added without touching the rest.
7
7
  */
8
8
  const Adjustments = [
9
- /* what was typed, exactly, always comes first; the same spelling in another case comes next */
10
- [1200, ({ name, needle }) => name === needle],
9
+ /*
10
+ * What was typed, exactly, always comes first, and the bonus is large enough to mean it: everything else
11
+ * together (a known name in base R, well downloaded, one place closer in the match) is worth about 1600,
12
+ * so typing `Sin` used to be answered with base R's `sin` first. Several packages exporting the same exact
13
+ * name all earn it, so the rules below still decide which of them leads.
14
+ * The same spelling in another case comes next.
15
+ */
16
+ [3000, ({ name, needle }) => name === needle],
11
17
  [900, ({ name, needle }) => name !== needle && name.toLowerCase() === needle.toLowerCase()],
12
18
  /* a real function from base R is what a reader usually means; a lone symbol almost never is */
13
19
  [40, ({ name, baseR }) => baseR === true && name.length >= 3],
package/util/version.js CHANGED
@@ -42,7 +42,7 @@ const assert_1 = require("./assert");
42
42
  const sigdb_download_1 = require("../project/sigdb/sigdb-download");
43
43
  const doc_files_1 = require("../documentation/doc-util/doc-files");
44
44
  // this is automatically replaced with the current version by release-it
45
- const version = '2.14.3';
45
+ const version = '2.14.4';
46
46
  // this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
47
47
  const versionDate = '2026-07-15T07:13:44Z';
48
48
  /**