dotnet / dotnet/docfx

[Bug] Namespace links created for non-existing parent namespaces

Open
#10,588 0 comments 2 reactions 0 assignees View on GitHub
template
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 9m
Merged PRs (30d)
11

Description

**Describe the bug**
For types, the generated pages contain a `Namespace` value. This consists of several links. However, this does not respect the project's `RootNamespace` anymore since version 2.65.2. Instead it creates a link for each namespace part, including non-existing parent namespaces. For instance, if my root namespace is `Foo.Bar.Baz`, the namespace contains the following links:
* `Foo` -> `Foo.html`
* `Bar` -> `Foo.Bar.html`
* `Baz` -> `Foo.Bar.Baz.html`

The problem is that `Foo.html` and `Foo.Bar.html` don't exist, leading to 404 errors.

Maybe I'm missing some configuration, but I tried several options including `globalNamespaceId` but the issue is not fixed. Downgrading to version 2.65.1 isn't possible because of #9047 and #9153.

**To Reproduce**
Minimal `docfx.json`:
```json
{
"metadata": [
{
"src": [
{
"files": [
"**.csproj"
],
"src": "../Foo.Bar.Baz"
}
],
"dest": "api"
}
],
"build": {
"content": [
{
"files": [
"api/**.yml"
]
},
{
"files": [
"toc.yml"
]
}
],
"dest": "_site"
}
}
```
The `Foo.Bar.Baz` project descriptor contains this:
```xml
Foo.Bar.Baz
```
Run `docfx docfx.json` from the directory where `docfx.json` is located.
This successfully generates the API pages but with the invalid links.

**Expected behavior**
* `Foo` is not a link
* `Bar` is not a link
* `Baz` is a link to `Foo.Bar.Baz.html`

**Screenshots**
Generated using version 2.65.1:
![Image](https://github.com/user-attachments/assets/6c3a2d0c-39f9-47f4-9b48-12f6aa9a11ae)

Generated using the latest version:
![Image](https://github.com/user-attachments/assets/457b0e18-fda6-44ac-85c8-deeb9728b69e)

**Context (please complete the following information):**
- Docfx version: 2.78.3
- Template: default

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.