@fern-api/fern-api-dev 5.75.4 → 5.75.5

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.
Files changed (2) hide show
  1. package/cli.cjs +183 -41
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -691149,7 +691149,7 @@ var AccessTokenPosthogManager = class {
691149
691149
  properties: {
691150
691150
  ...event,
691151
691151
  ...event.properties,
691152
- version: "5.75.4",
691152
+ version: "5.75.5",
691153
691153
  usingAccessToken: true,
691154
691154
  ...getRunIdProperties()
691155
691155
  }
@@ -691215,7 +691215,7 @@ var UserPosthogManager = class {
691215
691215
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
691216
691216
  event: "CLI",
691217
691217
  properties: {
691218
- version: "5.75.4",
691218
+ version: "5.75.5",
691219
691219
  ...event,
691220
691220
  ...event.properties,
691221
691221
  usingAccessToken: false,
@@ -872320,7 +872320,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
872320
872320
  var LOGS_FOLDER_NAME = "logs";
872321
872321
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
872322
872322
  function getCliSource() {
872323
- const version7 = "5.75.4";
872323
+ const version7 = "5.75.5";
872324
872324
  return `cli@${version7}`;
872325
872325
  }
872326
872326
  var DebugLogger = class {
@@ -875598,6 +875598,8 @@ var SnippetDependencyTracker = class {
875598
875598
  snippetToPages = /* @__PURE__ */ new Map();
875599
875599
  // Map: page file path -> Set of snippet files it references
875600
875600
  pageToSnippets = /* @__PURE__ */ new Map();
875601
+ // Whether a full scan has populated the maps at least once.
875602
+ hasBuiltInitialMap = false;
875601
875603
  constructor(context3) {
875602
875604
  this.context = context3;
875603
875605
  }
@@ -875643,21 +875645,77 @@ var SnippetDependencyTracker = class {
875643
875645
  const content5 = await (0, import_promises101.readFile)(markdownFile, "utf-8");
875644
875646
  const referencedFiles = this.extractReferences(content5, markdownFile, docsWorkspace.absoluteFilePath);
875645
875647
  this.pageToSnippets.set(markdownFile, referencedFiles);
875646
- for (const referencedFile of referencedFiles) {
875647
- if (!this.snippetToPages.has(referencedFile)) {
875648
- this.snippetToPages.set(referencedFile, /* @__PURE__ */ new Set());
875649
- }
875650
- this.snippetToPages.get(referencedFile)?.add(markdownFile);
875651
- }
875652
875648
  } catch (error50) {
875653
875649
  this.context.logger.debug(`Failed to read markdown file ${markdownFile}: ${error50}`);
875654
875650
  }
875655
875651
  }
875652
+ this.rebuildReverseMap();
875653
+ this.hasBuiltInitialMap = true;
875656
875654
  this.context.logger.debug(`Built dependency map: ${this.snippetToPages.size} snippets, ${this.pageToSnippets.size} pages`);
875657
875655
  } catch (error50) {
875658
875656
  this.context.logger.debug(`Failed to build dependency map: ${error50}`);
875659
875657
  }
875660
875658
  }
875659
+ /**
875660
+ * Incrementally updates the dependency maps for a set of changed markdown files,
875661
+ * avoiding a full re-scan of every page in the workspace.
875662
+ *
875663
+ * Only content-only (`.md`/`.mdx`) reloads take this path. For each changed file we
875664
+ * re-read it and recompute its outgoing references (the page -> snippets forward
875665
+ * edge); deleted files are dropped. We then rebuild the snippet -> pages reverse
875666
+ * map from the forward map in memory (no disk I/O), so the reverse map is always
875667
+ * fully consistent with the forward map and can never accumulate stale edges.
875668
+ *
875669
+ * Reloads never overlap (the watcher handler serializes them behind `isReloading`),
875670
+ * so these mutations are not subject to concurrent access. Falls back to a full
875671
+ * scan if an initial map has not been built yet.
875672
+ */
875673
+ async updateDependencyMapForFiles(changedFiles, project) {
875674
+ const docsWorkspace = project.docsWorkspaces;
875675
+ if (!docsWorkspace) {
875676
+ return;
875677
+ }
875678
+ if (!this.hasBuiltInitialMap) {
875679
+ await this.buildDependencyMap(project);
875680
+ return;
875681
+ }
875682
+ for (const changedFile of changedFiles) {
875683
+ const lower = changedFile.toLowerCase();
875684
+ if (!lower.endsWith(".md") && !lower.endsWith(".mdx")) {
875685
+ continue;
875686
+ }
875687
+ if (!await doesPathExist(changedFile)) {
875688
+ this.pageToSnippets.delete(changedFile);
875689
+ continue;
875690
+ }
875691
+ try {
875692
+ const content5 = await (0, import_promises101.readFile)(changedFile, "utf-8");
875693
+ const referencedFiles = this.extractReferences(content5, changedFile, docsWorkspace.absoluteFilePath);
875694
+ this.pageToSnippets.set(changedFile, referencedFiles);
875695
+ } catch (error50) {
875696
+ this.context.logger.debug(`Failed to read markdown file ${changedFile}: ${error50}`);
875697
+ this.pageToSnippets.delete(changedFile);
875698
+ }
875699
+ }
875700
+ this.rebuildReverseMap();
875701
+ }
875702
+ /**
875703
+ * Rebuilds the snippet -> pages (reverse) map from the page -> snippets (forward)
875704
+ * map. A pure in-memory transformation, so it can never leave stale reverse edges.
875705
+ */
875706
+ rebuildReverseMap() {
875707
+ this.snippetToPages.clear();
875708
+ for (const [page, references] of this.pageToSnippets) {
875709
+ for (const reference4 of references) {
875710
+ let pages = this.snippetToPages.get(reference4);
875711
+ if (pages == null) {
875712
+ pages = /* @__PURE__ */ new Set();
875713
+ this.snippetToPages.set(reference4, pages);
875714
+ }
875715
+ pages.add(page);
875716
+ }
875717
+ }
875718
+ }
875661
875719
  /**
875662
875720
  * Find all markdown files in the docs workspace directory
875663
875721
  */
@@ -876078,10 +876136,16 @@ async function runAppPreviewServer({ initialProject, reloadProject, validateProj
876078
876136
  context3.logger.info("Reloading docs...");
876079
876137
  const startTime = Date.now();
876080
876138
  void debugLogger.logCliReloadStart();
876139
+ const contentOnlyEdit = isContentOnlyEdit(editedAbsoluteFilepaths2);
876081
876140
  try {
876082
- project = await reloadProject();
876083
- await snippetTracker.buildDependencyMap(project);
876084
- if (!isContentOnlyEdit(editedAbsoluteFilepaths2)) {
876141
+ if (contentOnlyEdit) {
876142
+ context3.logger.debug("Content-only edit; reusing loaded project (skipping full reload).");
876143
+ await snippetTracker.updateDependencyMapForFiles(editedAbsoluteFilepaths2 ?? [], project);
876144
+ } else {
876145
+ project = await reloadProject();
876146
+ await snippetTracker.buildDependencyMap(project);
876147
+ }
876148
+ if (!contentOnlyEdit) {
876085
876149
  const validationStartTime = Date.now();
876086
876150
  void validateProject(project).then(() => {
876087
876151
  const validationTime = Date.now() - validationStartTime;
@@ -904909,7 +904973,7 @@ var LegacyDocsPublisher = class {
904909
904973
  previewId,
904910
904974
  disableTemplates: void 0,
904911
904975
  skipUpload,
904912
- cliVersion: "5.75.4",
904976
+ cliVersion: "5.75.5",
904913
904977
  loginCommand: "fern auth login"
904914
904978
  });
904915
904979
  if (taskContext.getResult() === TaskResult.Failure) {
@@ -935496,10 +935560,12 @@ function convertToPhpVariableName(name2) {
935496
935560
  // ../../../generators/php/codegen/lib/ast/Comment.js
935497
935561
  var Comment4 = class extends AstNode4 {
935498
935562
  docs;
935563
+ codeExample;
935499
935564
  tags = [];
935500
- constructor({ docs: docs2 } = {}) {
935565
+ constructor({ docs: docs2, codeExample } = {}) {
935501
935566
  super();
935502
935567
  this.docs = docs2;
935568
+ this.codeExample = codeExample;
935503
935569
  }
935504
935570
  addTag(tag2) {
935505
935571
  this.tags.push({
@@ -935513,6 +935579,17 @@ var Comment4 = class extends AstNode4 {
935513
935579
  this.docs.split("\n").forEach((line) => {
935514
935580
  writer2.writeLine(` * ${line}`);
935515
935581
  });
935582
+ if (this.codeExample != null || this.tags.length > 0) {
935583
+ writer2.writeLine(" *");
935584
+ }
935585
+ }
935586
+ if (this.codeExample != null) {
935587
+ writer2.writeLine(" * Example:");
935588
+ writer2.writeLine(" * ```php");
935589
+ this.codeExample.split("\n").forEach((line) => {
935590
+ writer2.writeLine(` * ${this.escapeDocs(line)}`.trimEnd());
935591
+ });
935592
+ writer2.writeLine(" * ```");
935516
935593
  if (this.tags.length > 0) {
935517
935594
  writer2.writeLine(" *");
935518
935595
  }
@@ -935522,6 +935599,9 @@ var Comment4 = class extends AstNode4 {
935522
935599
  }
935523
935600
  writer2.writeLine(" */");
935524
935601
  }
935602
+ escapeDocs(line) {
935603
+ return line.replaceAll("*/", "*\\/");
935604
+ }
935525
935605
  writeTag({ writer: writer2, tag: tag2 }) {
935526
935606
  const docsSplit = tag2.docs != null ? tag2.docs.split("\n") : void 0;
935527
935607
  if (docsSplit != null && docsSplit.length > 1) {
@@ -936694,10 +936774,11 @@ var Method4 = class extends AstNode4 {
936694
936774
  return_;
936695
936775
  body;
936696
936776
  docs;
936777
+ codeExample;
936697
936778
  classReference;
936698
936779
  static_;
936699
936780
  noBody;
936700
- constructor({ name: name2, access: access7, parameters: parameters2, throws, return_, body, docs: docs2, classReference: classReference4, static_, noBody }) {
936781
+ constructor({ name: name2, access: access7, parameters: parameters2, throws, return_, body, docs: docs2, codeExample, classReference: classReference4, static_, noBody }) {
936701
936782
  super();
936702
936783
  this.name = name2;
936703
936784
  this.access = access7;
@@ -936706,6 +936787,7 @@ var Method4 = class extends AstNode4 {
936706
936787
  this.return_ = return_;
936707
936788
  this.body = body;
936708
936789
  this.docs = docs2;
936790
+ this.codeExample = codeExample;
936709
936791
  this.classReference = classReference4;
936710
936792
  this.static_ = static_ ?? false;
936711
936793
  this.noBody = noBody ?? false;
@@ -936739,7 +936821,7 @@ var Method4 = class extends AstNode4 {
936739
936821
  }
936740
936822
  }
936741
936823
  writeComment(writer2) {
936742
- const comment6 = new Comment4({ docs: this.docs });
936824
+ const comment6 = new Comment4({ docs: this.docs, codeExample: this.codeExample });
936743
936825
  for (const parameter6 of this.parameters) {
936744
936826
  comment6.addTag({
936745
936827
  tagType: "param",
@@ -942729,7 +942811,8 @@ var Method6 = class extends AstNode6 {
942729
942811
  statements;
942730
942812
  returnType;
942731
942813
  splatOptionDocs;
942732
- constructor({ name: name2, docstring, kind, visibility, parameters: parameters2, returnType, statements, splatOptionDocs }) {
942814
+ codeExample;
942815
+ constructor({ name: name2, docstring, kind, visibility, parameters: parameters2, returnType, statements, splatOptionDocs, codeExample }) {
942733
942816
  super();
942734
942817
  this.name = name2;
942735
942818
  this.docstring = docstring;
@@ -942743,6 +942826,7 @@ var Method6 = class extends AstNode6 {
942743
942826
  this.returnType = returnType ?? Type35.untyped();
942744
942827
  this.statements = statements ?? [];
942745
942828
  this.splatOptionDocs = splatOptionDocs ?? [];
942829
+ this.codeExample = codeExample;
942746
942830
  }
942747
942831
  addStatement(statement) {
942748
942832
  this.statements.push(statement);
@@ -942788,8 +942872,18 @@ var Method6 = class extends AstNode6 {
942788
942872
  for (const optionDoc of this.splatOptionDocs) {
942789
942873
  writer2.writeLine(`# ${optionDoc}`);
942790
942874
  }
942875
+ const codeExample = this.codeExample?.trim();
942876
+ if (codeExample) {
942877
+ if (this.docstring || hasAnyParameters || this.splatOptionDocs.length > 0) {
942878
+ writer2.writeLine("#");
942879
+ }
942880
+ writer2.writeLine("# @example");
942881
+ for (const line of codeExample.split("\n")) {
942882
+ writer2.writeLine(line.trim() === "" ? "#" : `# ${line.trimEnd()}`);
942883
+ }
942884
+ }
942791
942885
  if (this.returnType != null) {
942792
- if (hasAnyParameters || this.docstring) {
942886
+ if (hasAnyParameters || this.docstring || codeExample) {
942793
942887
  writer2.writeLine("#");
942794
942888
  }
942795
942889
  writer2.write(`# @return [`);
@@ -946231,7 +946325,7 @@ var DocComment = class extends AstNode7 {
946231
946325
  examples;
946232
946326
  constructor({ summary, description, parameters: parameters2, returns, errors: errors4, examples }) {
946233
946327
  super();
946234
- this.summary = this.sanitizeText(summary);
946328
+ this.summary = summary ? this.sanitizeText(summary) : void 0;
946235
946329
  this.description = description ? this.sanitizeText(description) : void 0;
946236
946330
  this.parameters = (parameters2 ?? []).map((param) => ({
946237
946331
  name: param.name,
@@ -946241,15 +946335,25 @@ var DocComment = class extends AstNode7 {
946241
946335
  this.examples = (examples ?? []).map((e2) => this.sanitizeText(e2));
946242
946336
  }
946243
946337
  write(writer2) {
946244
- this.writeMultilineText(writer2, this.summary);
946338
+ let hasContent = false;
946339
+ if (this.summary) {
946340
+ this.writeMultilineText(writer2, this.summary);
946341
+ hasContent = true;
946342
+ }
946245
946343
  if (this.description) {
946246
- writer2.write("///");
946247
- writer2.newLine();
946344
+ if (hasContent) {
946345
+ writer2.write("///");
946346
+ writer2.newLine();
946347
+ }
946248
946348
  this.writeMultilineText(writer2, this.description);
946349
+ hasContent = true;
946249
946350
  }
946250
946351
  if (this.parameters.length > 0) {
946251
- writer2.write("///");
946252
- writer2.newLine();
946352
+ if (hasContent) {
946353
+ writer2.write("///");
946354
+ writer2.newLine();
946355
+ }
946356
+ hasContent = true;
946253
946357
  writer2.write("/// # Arguments");
946254
946358
  writer2.newLine();
946255
946359
  writer2.write("///");
@@ -946267,8 +946371,11 @@ var DocComment = class extends AstNode7 {
946267
946371
  });
946268
946372
  }
946269
946373
  if (this.returns) {
946270
- writer2.write("///");
946271
- writer2.newLine();
946374
+ if (hasContent) {
946375
+ writer2.write("///");
946376
+ writer2.newLine();
946377
+ }
946378
+ hasContent = true;
946272
946379
  writer2.write("/// # Returns");
946273
946380
  writer2.newLine();
946274
946381
  writer2.write("///");
@@ -946280,16 +946387,18 @@ var DocComment = class extends AstNode7 {
946280
946387
  });
946281
946388
  }
946282
946389
  if (this.examples.length > 0) {
946283
- writer2.write("///");
946284
- writer2.newLine();
946390
+ if (hasContent) {
946391
+ writer2.write("///");
946392
+ writer2.newLine();
946393
+ }
946285
946394
  writer2.write("/// # Examples");
946286
946395
  writer2.newLine();
946287
946396
  writer2.write("///");
946288
946397
  writer2.newLine();
946289
946398
  this.examples.forEach((example) => {
946290
- writer2.write("/// ```rust");
946399
+ writer2.write("/// ```no_run");
946291
946400
  writer2.newLine();
946292
- this.writeMultilineText(writer2, example);
946401
+ this.writeCodeBlock(writer2, example);
946293
946402
  writer2.write("/// ```");
946294
946403
  writer2.newLine();
946295
946404
  });
@@ -946303,6 +946412,14 @@ var DocComment = class extends AstNode7 {
946303
946412
  writer2.newLine();
946304
946413
  }
946305
946414
  }
946415
+ writeCodeBlock(writer2, code5) {
946416
+ const lines = code5.split("\n");
946417
+ for (const line of lines) {
946418
+ const trimmed2 = line.trimEnd();
946419
+ writer2.write(trimmed2.length > 0 ? `/// ${trimmed2}` : "///");
946420
+ writer2.newLine();
946421
+ }
946422
+ }
946306
946423
  /**
946307
946424
  * Sanitizes text content to ensure it doesn't break Rust doc comment syntax.
946308
946425
  */
@@ -952079,13 +952196,15 @@ var ComputedProperty = class extends AstNode8 {
952079
952196
  var DocComment2 = class _DocComment extends AstNode8 {
952080
952197
  summary;
952081
952198
  description;
952199
+ codeExample;
952082
952200
  parameters;
952083
952201
  returns;
952084
952202
  throws;
952085
- constructor({ summary, description, parameters: parameters2, returns, throws }) {
952203
+ constructor({ summary, description, codeExample, parameters: parameters2, returns, throws }) {
952086
952204
  super();
952087
- this.summary = _DocComment.sanitizeText(summary);
952205
+ this.summary = summary != null ? _DocComment.sanitizeText(summary) : void 0;
952088
952206
  this.description = description != null ? _DocComment.sanitizeText(description) : void 0;
952207
+ this.codeExample = codeExample != null ? _DocComment.sanitizeText(codeExample) : void 0;
952089
952208
  this.parameters = (parameters2 ?? []).map((param) => ({
952090
952209
  name: param.name,
952091
952210
  description: _DocComment.sanitizeText(param.description)
@@ -952094,15 +952213,34 @@ var DocComment2 = class _DocComment extends AstNode8 {
952094
952213
  this.throws = (throws ?? []).map((t3) => _DocComment.sanitizeText(t3));
952095
952214
  }
952096
952215
  write(writer2) {
952097
- this.writeMultilineText(writer2, this.summary);
952216
+ let hasPrecedingSection = false;
952217
+ if (this.summary != null) {
952218
+ this.writeMultilineText(writer2, this.summary);
952219
+ hasPrecedingSection = true;
952220
+ }
952098
952221
  if (this.description != null) {
952099
- writer2.write("///");
952100
- writer2.newLine();
952222
+ if (hasPrecedingSection) {
952223
+ writer2.write("///");
952224
+ writer2.newLine();
952225
+ }
952101
952226
  this.writeMultilineText(writer2, this.description);
952227
+ hasPrecedingSection = true;
952228
+ }
952229
+ if (this.codeExample != null) {
952230
+ if (hasPrecedingSection) {
952231
+ writer2.write("///");
952232
+ writer2.newLine();
952233
+ }
952234
+ this.writeMultilineText(writer2, `\`\`\`swift
952235
+ ${this.codeExample}
952236
+ \`\`\``);
952237
+ hasPrecedingSection = true;
952102
952238
  }
952103
952239
  if (this.parameters.length > 0) {
952104
- writer2.write("///");
952105
- writer2.newLine();
952240
+ if (hasPrecedingSection) {
952241
+ writer2.write("///");
952242
+ writer2.newLine();
952243
+ }
952106
952244
  for (const param of this.parameters) {
952107
952245
  const paramLines = param.description.split("\n");
952108
952246
  paramLines.forEach((line, lineIdx) => {
@@ -952151,8 +952289,12 @@ var DocComment2 = class _DocComment extends AstNode8 {
952151
952289
  writeMultilineText(writer2, sanitizedText) {
952152
952290
  const lines = sanitizedText.split("\n");
952153
952291
  for (const line of lines) {
952154
- writer2.write("/// ");
952155
- writer2.write(line);
952292
+ if (line === "") {
952293
+ writer2.write("///");
952294
+ } else {
952295
+ writer2.write("/// ");
952296
+ writer2.write(line);
952297
+ }
952156
952298
  writer2.newLine();
952157
952299
  }
952158
952300
  }
@@ -971744,7 +971886,7 @@ function getAutomationContextFromEnv() {
971744
971886
  config_branch: process.env.FERN_CONFIG_BRANCH,
971745
971887
  config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
971746
971888
  trigger: process.env.GITHUB_EVENT_NAME,
971747
- cli_version: "5.75.4"
971889
+ cli_version: "5.75.5"
971748
971890
  };
971749
971891
  }
971750
971892
  function isAutomationMode() {
@@ -972576,7 +972718,7 @@ var CliContext = class _CliContext {
972576
972718
  if (false) {
972577
972719
  this.logger.error("CLI_VERSION is not defined");
972578
972720
  }
972579
- return "5.75.4";
972721
+ return "5.75.5";
972580
972722
  }
972581
972723
  getCliName() {
972582
972724
  if (false) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.75.4",
2
+ "version": "5.75.5",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",