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

Links on typedef's do not maintain the base path #50

Closed
jayesbe opened this issue Nov 2, 2018 · 3 comments
Closed

Links on typedef's do not maintain the base path #50

jayesbe opened this issue Nov 2, 2018 · 3 comments
Labels
bug v3 Fixed or implemented. To be released.

Comments

@jayesbe
Copy link

jayesbe commented Nov 2, 2018

I am noticing that typedef's do not maintain the base path when links are generated.

  "app": {
    "title": " SDK Documentation",
    "entrance": "content:readme",
    "routing": {
      "method": "path"
    },
    "base": "/pages/Development/sdk",
    "server": "github"
  },

results in

<div id="Foo~bar" class="symbol-container">
  <div class="symbol-heading">
    <div class="symbol">
      <a href="/pages/Development/sdk/api#Foo~bar">
        <svg class="svg-inline--fa fa-link fa-w-16 color-gray-light" aria-hidden="true" data-prefix="fas" data-icon="link" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg="">...</svg>
      </a>
      <code class="symbol-name">Foo<span class="color-blue">~</span>bar(params)</code>
      <span class="symbol-sep"></span>
      <code class="symbol-type">
        <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">Promise</a>&lt;<a href="/api/#Foo.BarResponse">Foo.BarResponse</a>&gt;</code>&nbsp;&nbsp;<span class="boxed vertical-middle bg-ice-dark opacity-full">inner</span>
      </div>
    </div>
    <div class="symbol-definition">
      <div class="symbol-info"></div>
      <p></p>
      <div class="space-top-sm space-bottom-xs fw-bold">Parameters</div>
      <ul class="param-list">
        <li>
          <div class="param-meta clearfix"><span class="inline-block space-right-sm"><code><span class="fw-bold">params</span></code>&nbsp;:&nbsp;<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" target="_blank">Object</a></code></span><span class="param-info-box"><span class="param-info required boxed">Required</span></span>
          </div>
          <div class="param-desc"><p></p></div>
        </li>
        <li>
          <div class="param-meta clearfix"><span class="inline-block space-right-sm"><code><span class="color-gray">params</span><span class="fw-bold"><span class="color-blue">.</span>items</span></code>&nbsp;:&nbsp;<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" target="_blank">Array</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>&gt;</code></span><span class="param-info-box"><span class="param-info required boxed">Required</span></span>
          </div>
          <div class="param-desc"><p></p></div>
        </li>
      </ul>  
      <p><b class="caption">Returns:</b>&nbsp;&nbsp;<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" target="_blank">Promise</a>&lt;<a href="/api/#Foo.BarResponse">Foo.BarResponse</a>&gt;</code></p>
    </div>
  </div>

We can see that the /pages/Development/sdk/api#Foo~bar is generated correctly.. however the /api/#Foo.BarResponse link is missing the base path prefix.

@jayesbe
Copy link
Author

jayesbe commented Nov 2, 2018

I see this in DocmaWeb.js

DocmaWeb.prototype._fixAnchors = function (cb) {
    if (this.app.base) {
        setTimeout(function () {
            var i, el,
                nodes = document.querySelectorAll('a[href^="#"]');
            for (i = 0; i < nodes.length; i++) {
                el = nodes[i];
                var href = el.getAttribute('href');
                if (href.slice(0, 1) === '#' && href.length > 1) {
                    href = window.location.pathname + (window.location.search || '') + href;
                    el.setAttribute('href', href);
                }
            }
            if (typeof cb === 'function') cb();
        }, 50);
    }
};

seems like the links do not get updated because of the prepended /api/ before the # resulting in those links getting skipped over...

@onury onury added bug and removed bug labels Nov 16, 2018
@onury
Copy link
Owner

onury commented Nov 17, 2018

Thanks for reporting.

Docma adds a $docmaLink property to each symbol to be used by the template for internal linking. When routing method is set to "path", the link was preceded with a / which makes it an absolute path rather than a relative path which is required for it to work with the app.base path.

Fixed. Will be available in next release.

@onury onury added Fixed or implemented. To be released. v3 labels Nov 17, 2018
@onury
Copy link
Owner

onury commented Nov 18, 2018

Fixed with Docma v3.0.0.

@onury onury closed this as completed Nov 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v3 Fixed or implemented. To be released.
Projects
None yet
Development

No branches or pull requests

2 participants