@webneat/codewiki 0.0.5 → 0.0.6

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.
package/dist/bin.js CHANGED
@@ -552,7 +552,7 @@ var symbols2 = {
552
552
  where: {}
553
553
  };
554
554
  var external_dependencies2 = {
555
- select: ["id", "package", "subpath", "name", "state", "error"],
555
+ select: ["id", "package", "subpath", "name", "is_builtin", "state", "error"],
556
556
  order_by: ["id", "asc"],
557
557
  limit: 20,
558
558
  offset: 0,
@@ -2913,12 +2913,23 @@ var describe = new Command3("describe");
2913
2913
  describe.description("Show the next item to describe");
2914
2914
  describe.action(async () => {
2915
2915
  const wiki = await load_wiki();
2916
- const next = get_next_to_describe(wiki);
2917
- if (!next) return env.log("All items are described!");
2918
- if (next.type === "dependency") return describe_dependency(next.entity);
2919
- env.log(
2920
- `All external dependencies are described, and we don't support describing other items yet (we are implementing the right order ...). You are done for now!`
2921
- );
2916
+ const result = wiki.to_describe(1);
2917
+ if (result.type === "none") {
2918
+ return env.log("All items are described!");
2919
+ }
2920
+ if (result.type === "dependencies" && result.items.length > 0) {
2921
+ return describe_dependency(result.items[0]);
2922
+ }
2923
+ if (result.type === "symbols" && result.items.length > 0) {
2924
+ return describe_symbol(wiki, result.items[0]);
2925
+ }
2926
+ if (result.type === "files" && result.items.length > 0) {
2927
+ return describe_file(result.items[0]);
2928
+ }
2929
+ if (result.type === "directories" && result.items.length > 0) {
2930
+ return describe_directory(result.items[0]);
2931
+ }
2932
+ env.log("No items to describe.");
2922
2933
  });
2923
2934
  function describe_dependency(dep) {
2924
2935
  env.log(dedent2`
@@ -2934,40 +2945,42 @@ function describe_dependency(dep) {
2934
2945
  \`codewiki dependencies set-description ${dep.id} <markdown-file>\`
2935
2946
  `);
2936
2947
  }
2937
- function get_next_to_describe(wiki) {
2938
- const deps = wiki.dependencies.search({
2939
- where: { state: "to_describe" },
2940
- limit: 1,
2941
- select: ["id", "package", "subpath", "name", "version", "github_repo"]
2942
- });
2943
- if (deps.length > 0) {
2944
- return { type: "dependency", entity: deps[0] };
2945
- }
2946
- const symbols4 = wiki.symbols.search({
2947
- where: { state: "to_describe" },
2948
- limit: 1,
2949
- select: ["id", "name", "type", "file_id", "is_exported"]
2950
- });
2951
- if (symbols4.length > 0) {
2952
- return { type: "symbol", entity: symbols4[0] };
2953
- }
2954
- const files5 = wiki.files.search({
2955
- where: { state: "to_describe" },
2956
- limit: 1,
2957
- select: ["id", "path"]
2958
- });
2959
- if (files5.length > 0) {
2960
- return { type: "file", entity: files5[0] };
2961
- }
2962
- const directories4 = wiki.directories.search({
2963
- where: { state: "to_describe" },
2964
- limit: 1,
2965
- select: ["id", "path"]
2966
- });
2967
- if (directories4.length > 0) {
2968
- return { type: "directory", entity: directories4[0] };
2969
- }
2970
- return null;
2948
+ function describe_symbol(wiki, sym) {
2949
+ const file = wiki.files.get(sym.file_id);
2950
+ env.log(dedent2`
2951
+ Your task is to describe the following symbol:
2952
+
2953
+ name: ${sym.name}
2954
+ type: ${sym.type}
2955
+ file: ${file?.path || "unknown"}
2956
+ exported: ${sym.is_exported}
2957
+
2958
+ Write a concise developer documentation for this ${sym.type} into a markdown file, then run:
2959
+
2960
+ codewiki symbols set-description ${sym.id} <markdown-file>
2961
+ `);
2962
+ }
2963
+ function describe_file(file) {
2964
+ env.log(dedent2`
2965
+ Your task is to describe the following file:
2966
+
2967
+ path: ${file.path}
2968
+
2969
+ Write a concise description of this file's purpose and contents into a markdown file, then run:
2970
+
2971
+ codewiki files set-description ${file.id} <markdown-file>
2972
+ `);
2973
+ }
2974
+ function describe_directory(dir) {
2975
+ env.log(dedent2`
2976
+ Your task is to describe the following directory:
2977
+
2978
+ path: ${dir.path}
2979
+
2980
+ Write a concise description of this directory's purpose and contents into a markdown file, then run:
2981
+
2982
+ codewiki directories set-description ${dir.id} <markdown-file>
2983
+ `);
2971
2984
  }
2972
2985
 
2973
2986
  // src/cli/commands/files/index.ts