DDoc Reference Links point to /docs/docs instead of /docs?

Vijay Nayar madric at gmail.com
Mon Feb 21 11:34:42 UTC 2022


Greetings everyone,

I have a question regarding the use of [relative 
links](https://dlang.org/spec/ddoc.html#reference_links) in DDoc. 
According to the specification, you can include a reference to an 
object that is in scope using square brackets, e.g. `[Object]`.

One of my current projects is to add support to 
[Avro](https://avro.apache.org/docs/current/index.html) in D, and 
I encountered something unusual. Consider the following code 
snippets.

```d
// File: source/avro/parser.d
module avro.parser;
class Parser {
   /// Builds a [Schema] using a path to a ".avsc" file.
   public Schema parseFile(string fileName) {
     // ...
   }
```

```d
// File: source/avro/schema.d
module avro.schema;
class Schema {
   // ...
}
```

When I build the documentation using `dub build -b docs`, which 
creates a bunch of individual `.html` files under the `docs` 
folder, but there is no `index.html` or anything else. I start by 
browsing to `file:///home/vnayar/projects/avro-d/docs/parser.html`

The documentation for the `Parser::parseFile` creates a link like 
so:
```html
<!-- File: docs/parser.html -->
<div class="ddoc_decl">
   <section class="section ddoc_sections">
   <div class="ddoc_summary">
   <p class="para">
     Builds a <a href="docs/schema.html#Schema"><code 
class="code">Schema</code></a> using a path to a ".avsc" file.
   </p>
</div>
```

However, when I click the `Schema` link in my browser, the 
relative link of `docs/schema.html` actually is relative to the 
current file, thus, it takes me to 
`file:///home/vnayar/projects/avro-d/docs/docs/schema.html#Schema`. Because the folder `docs/docs` does not exist, I just get a file-not-found error.

Am I using DDocs incorrectly?


More information about the Digitalmars-d-learn mailing list