Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken examples after update #9495

Closed
bkoelman opened this issue Dec 2, 2023 · 7 comments
Closed

Broken examples after update #9495

bkoelman opened this issue Dec 2, 2023 · 7 comments
Labels
bug A bug to fix dotnet: xml-comment XML comment for .NET API reference docs
Milestone

Comments

@bkoelman
Copy link

bkoelman commented Dec 2, 2023

Describe the bug

After update from 2.74.0 to 2.74.1, examples are broken. See json-api-dotnet/JsonApiDotNetCore#1415 (comment).

To Reproduce

  1. Clone the repo at /~https://github.com/json-api-dotnet/JsonApiDotNetCore
  2. cd docs
  3. ./build-dev.ps1
  4. In the browser, navigate to Getting Started > API > JsonApiOptions

Expected behavior
No broken HTML.

@bkoelman bkoelman added the bug A bug to fix label Dec 2, 2023
@yufeih yufeih added this to the Backlog milestone Dec 3, 2023
@yufeih yufeih added the dotnet: xml-comment XML comment for .NET API reference docs label Dec 3, 2023
@yufeih
Copy link
Contributor

yufeih commented Dec 15, 2023

Seems to be working just fine:

image

@bkoelman
Copy link
Author

Did you try on Ubuntu?

You can see the diff by downloading and extracting the documentation artifact from /~https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/runs/7055097802 and /~https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/runs/7208009175.

The next screenshot shows the diff:
image

Here's what it looks like in Chrome:
image

@bkoelman
Copy link
Author

Well, it does not render entirely correct in v2.74.0 on Windows either:

    /// <summary>
    /// Whether to use relative links for all resources. <c>false</c> by default.
    /// </summary>
    /// <example>
    /// <code><![CDATA[
    /// options.UseRelativeLinks = true;
    /// ]]></code>
    /// <code><![CDATA[
    /// {
    ///   "type": "articles",
    ///   "id": "4309",
    ///   "relationships": {
    ///      "author": {
    ///        "links": {
    ///          "self": "/api/shopping/articles/4309/relationships/author",
    ///          "related": "/api/shopping/articles/4309/author"
    ///        }
    ///      }
    ///   }
    /// }
    /// ]]></code>
    /// </example>
    bool UseRelativeLinks { get; }

image

yufeih added a commit that referenced this issue Dec 18, 2023
* test: code in C# documentation comment #9495

* ignoreLineEndingDifferences
@bkoelman
Copy link
Author

bkoelman commented Jan 24, 2024

This is broken even worse in v2.75.1.

What it should look like (from https://www.jsonapi.net/api/JsonApiDotNetCore.Configuration.JsonApiOptions.html, which was built using v2.74.0), except for the incorrect curly indent:

image

What it does look like in v2.75.1 instead:

image

The first red arrow is new: it copies the class/interface-level comment and puts that as documentation for bool.

The source code comments can be found at: /~https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs#L57-L79

The docfx output for v2.75.1 is available as a downloadable build artifact at /~https://github.com/json-api-dotnet/JsonApiDotNetCore/actions/runs/7633561767?pr=1440. Extract documentation.zip and edit file JsonApiDotNetCore.Configuration.JsonApiOptions.html, which contains the following HTML snippet:

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public bool UseRelativeLinks { get; set; }</code></pre>
  </div>





  <h4 class="section">Property Value</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd>Global options that configure the behavior of JsonApiDotNetCore.</dd>
  </dl>



  <h4 class="section" id="JsonApiDotNetCore_Configuration_JsonApiOptions_UseRelativeLinks_examples">Examples</h4>
  <pre><code>        &lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;options.UseRelativeLinks = true;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;{
</code></pre>
<p>&quot;type&quot;: &quot;articles&quot;,
&quot;id&quot;: &quot;4309&quot;,
&quot;relationships&quot;: {
&quot;author&quot;: {
&quot;links&quot;: {
&quot;self&quot;: &quot;/api/shopping/articles/4309/relationships/author&quot;,
&quot;related&quot;: &quot;/api/shopping/articles/4309/author&quot;
}
}
}
}</p>

Specifically, the part:

<pre><code>        &lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;options.UseRelativeLinks = true;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class=&quot;lang-csharp&quot;&gt;{
</code></pre>

explains why it's rendered incorrectly. The text inside <pre> should not be escaped.

@yufeih Can you take another look? Please let me know what else you need to reproduce this.

Environment

Google Chrome version: 120.0.6099.225 (Official Build) (64-bit)

> dotnet --info
.NET SDK:
 Version:           8.0.101
 Commit:            6eceda187b
 Workload version:  8.0.100-manifests.1c08acc9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.101\

.NET workloads installed:
 Workload version: 8.0.100-manifests.1c08acc9
There are no installed workloads to display.

Host:
  Version:      8.0.1
  Architecture: x64
  Commit:       bf5e279d92

.NET SDKs installed:
  8.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

@filzrev
Copy link
Contributor

filzrev commented Feb 12, 2024

HTML escape problems seem to occur when using both examples and `' tags.

Minimum reproducible source code

namespace Examples;

public interface IJsonApiOptions
{
    /// <summary>
    /// Whether to use relative links for all resources. <c>false</c> by default.
    /// </summary>
    /// <example>
    /// <code><![CDATA[
    /// options.UseRelativeLinks = true;
    /// ]]></code>
    /// <code><![CDATA[
    /// {
    ///   "type": "articles",
    ///   "id": "4309",
    ///   "relationships": {
    ///      "author": {
    ///        "links": {
    ///          "self": "/api/shopping/articles/4309/relationships/author",
    ///          "related": "/api/shopping/articles/4309/author"
    ///        }
    ///      }
    ///   }
    /// }
    /// ]]></code>
    /// </example>
    public bool UseRelativeLinks { get; }

}

public class JsonApiOptions : IJsonApiOptions
{
    /// <inheritdoc/>
    public bool UseRelativeLinks { get; }
}

@bkoelman
Copy link
Author

I've created a minimal repro at #9736.

@bkoelman
Copy link
Author

bkoelman commented Apr 8, 2024

Closing, this was fixed in v2.76.0.

@bkoelman bkoelman closed this as completed Apr 8, 2024
p-kostov pushed a commit to ErpNetDocs/docfx that referenced this issue Jun 28, 2024
* test: code in C# documentation comment dotnet#9495

* ignoreLineEndingDifferences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix dotnet: xml-comment XML comment for .NET API reference docs
Projects
None yet
Development

No branches or pull requests

3 participants