chitralverma opened a new issue, #9334:
URL: https://github.com/apache/opendal/issues/9334

   *Drafted with AI assistance (Claude Code, Claude Opus 5.5); the author is 
accountable for it.*
   
   ### Feature Description
   
   The binding generators in `dev/src/generate/` copy core's Rust doc comments 
into each binding's generated `Capability`, `Metadata`, and (in progress) 
options docs. The text keeps Rust identifiers, paths, and intra-doc link syntax 
that do not exist in the binding. I propose a small shared doc post-processor 
that translates those references into each binding's names.
   
   ### Problem and Solution
   
   **Examples on `main` (79a688b):**
   
   - Node.js `writeCanCopyFrom` says "`Writer::copy_from` remains available…": 
[generated.d.ts#L156](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/nodejs/generated.d.ts#L156).
 The same sentence appears in Java 
[Capability.java#L180](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/java/src/main/java/org/apache/opendal/Capability.java#L180),
 .NET 
[Capability.cs#L279](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/dotnet/OpenDAL/Capability.cs#L279),
 and C 
[opendal.h#L945](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/c/include/opendal.h#L945).
   - `write_with_checksum` keeps the raw intra-doc link 
`[`crate::WriteChecksum::Any`]` in every binding, for example Node.js 
[generated.d.ts#L182](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/nodejs/generated.d.ts#L182),
 Go 
[capability.go#L347](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/go/capability.go#L347),
 C++ 
[capability.hpp#L189](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/cpp/include/capability.hpp#L189),
 and Python 
[capability.pyi#L299](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/python/python/opendal/capability.pyi#L299).
 OCaml escapes the brackets, giving `\[`crate::WriteChecksum::Any`\]`: 
[capability.mli#L156](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/bindings/ocaml/lib/capability.mli#L156).
   - Options generation (#9320) carries the problem into option docs. In #9333 
the Node.js `ListOptions` docs say "Setting this requires 
`Capability::list_with_start_after`" where Node.js exposes 
`listWithStartAfter`, and point to `crate::layers::SimulateLayer` and the 
`auto-simulate` Cargo feature: 
[generated.d.ts#L1243-L1251](https://github.com/apache/opendal/blob/3639cec3850043f5df3d706d1dcfc64d6038cc52/bindings/nodejs/generated.d.ts#L1243-L1251)
 (PR head 3639cec). #9331 (C++) and #9332 (Python) share the same source text.
   
   **How the generators handle docs today:**
   
   - The shared parsers return raw doc text: 
[`options::doc_lines`](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/options.rs#L169),
 used by 
[`capability.rs#L84`](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/capability.rs#L84)
 and 
[`metadata.rs#L136`](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/metadata.rs#L136).
   - Capability and Metadata generators pass that text through unchanged 
([nodejs.rs#L111](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/nodejs.rs#L111),
 
[c.rs#L98](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/c.rs#L98)
 for C and Go, 
[cpp.rs#L237](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/cpp.rs#L237),
 
[java.rs#L296](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/java.rs#L296)),
 or only escape it 
([dotnet.rs#L226](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/dotnet.rs#L226)
 XML-escapes, 
[ocaml.rs#L187](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/ocaml.rs#L187)
 escapes odoc markup).
   - Java and .NET option docs already translate links, each with its own copy: 
[`option_javadoc_token`](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/java.rs#L917)
 maps `Capability::*`, `Metadata::*`, and option fields to `{@link …}`, and 
[`DocCtx::path`](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/dotnet.rs#L842)
 maps them to `<see cref=…/>`. Neither applies to Capability or Metadata docs.
   - The website generator drops every sentence that contains `::` 
([capabilities_docs.rs#L267](https://github.com/apache/opendal/blob/79a688bb5153a1748138d07325de7881c0be03cb/dev/src/generate/capabilities_docs.rs#L267)).
   
   **Proposed direction:**
   
   Add a small shared doc post-processor next to the shared parsers 
(`capability.rs`, `metadata.rs`, `core_options.rs`) that:
   
   1. Parses inline rustdoc markup once: intra-doc links (`[`path`]`, 
`[label][path]`), Markdown links, and code spans.
   2. Resolves known core identifiers (capability fields, metadata accessors, 
option structs and fields, and operation method names) to each binding's names 
through a per-binding naming function, for example camelCase for Node.js and 
Java, PascalCase for .NET and Go, snake_case for Python, and the `opendal_*` 
names for C. Each binding then renders the result in its own doc syntax 
(`{@link}`, `<see cref>`, plain code span).
   3. Leaves unknown Rust paths as plain code spans, or drops them where a 
binding has no equivalent (for example `crate::layers::SimulateLayer`, Cargo 
feature names).
   
   The Java and .NET option translators would become per-binding naming and 
rendering on top of the shared parser.
   
   Out of scope: rewriting prose. Sentences that describe Rust-only behavior 
stay a per-binding override, as the existing Node.js metadata notes do.
   
   ### Additional Context
   
   Related: #9320 (options for all bindings), #9122 (Capability), #9129 
(Metadata).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to