outmoded / lout

API documentation generator
Other
276 stars 49 forks source link

Possible formatting error in templates-->route.html #164

Closed webbpinner closed 7 years ago

webbpinner commented 7 years ago

I just integrated lout within my hapi project and had an issue with the route view. The CORS section starting on the last line of the auth section. Looking at the code it appeared that the auth section was using <p>/<h4> for the individual rows vs the rest of the template which was using <dl>,<dt><dd>. I converted the auth section of the template to use the <dl>,<dt><dd> and normalized some indentation discrepancies. That didn't fix the problem but it did make the resulting code more consistent. What ultimately did fix the problem was adding a <br/> just before the closing {{/if}} for the auth section.

Thought I'd share in case this was in fact a bug.

Cheers, -W

Below is my replacement for the existing auth section in the routes template:

                <h3 class="auth">Authentication</h3>
                <dl>
                    <dt class="auth-header auth-strategies">Strategies</dt>
                    <dd class="auth-value auth-strategies">{{this.auth.strategies}}</dd>
                    <dt class="auth-header auth-mode">Mode</dt>
                    <dd class="auth-value auth-mode">{{this.auth.mode}}</dd>
                    {{#if this.auth.payload}}
                    <dt class="auth-header auth-payload">Payload</dt>
                    <dd class="auth-value auth-payload">{{this.auth.payload}}</dd>
                    {{/if}}
                </dl>
                    {{#if this.auth.access}}
                <dl>
                    <dt class="auth-header auth-scope">Scopes</dt>
                    <dd>
                        <ul class="auth-access">
                        {{#each this.auth.access}}
                            <li>
                            {{#if this.scope}}
                                {{#if this.scope.required}}
                                <dt> class="auth-header auth-scope">Required</dt>
                                <dd class="auth-value auth-scope">{{this.scope.required}}</dd>
                                {{/if}}
                                {{#if this.scope.selection}}
                                <dt class="auth-header auth-scope">Selection</dt>
                                <dd class="auth-value auth-scope">{{this.scope.selection}}</dd>
                                {{/if}}
                                {{#if this.scope.forbidden}}
                                <dt class="auth-header auth-scope">Forbidden</dt>
                                <dd class="auth-value auth-scope">{{this.scope.forbidden}}</dd>
                                {{/if}}
                            {{/if}}
                            {{#if this.entity}}
                                <dt class="auth-header auth-entity">Entity</dt>
                                <dd class="auth-value auth-entity">{{this.entity}}</dd>
                            {{/if}}
                            </li>
                        {{/each}}
                        </ul>
                    </dd>
                </dl>
                    {{/if}}
                    {{#if this.auth.tos}}
                <dl>
                    <dt class="auth-header auth-tos">Terms of service</dt>
                    <dd class="auth-value auth-tos">{{this.auth.tos}}</dd>
                </dl>
                    {{/if}}
                <br />
                {{/if}}
Marsup commented 7 years ago

Not sure what you mean. Can you screenshot what's wrong on the demo site (http://lout.herokuapp.com/docs?server=http://lout.herokuapp.com&path=/withcorstrue#GET) ?

webbpinner commented 7 years ago

My bad, should have done that in the first place. Original:

old

Modified:

new

I'm suggesting there may be an issue when auth is required and CORS is true.

Marsup commented 7 years ago

Looks better indeed, I'm probably lacking a route test case for auth + CORS. Do you mind taking a stab at a patch ?

webbpinner commented 7 years ago

Just created a pull request. There appears to be some sort of auto-build process that is indicating build errors although they do not cite errors in the route.html file. Is there anything I need to do to make this pull request compatible with the master branch?

Marsup commented 7 years ago

I will, it's been an outstanding issue for a while now, I need to fix it, but I'll have to require latest versions of everything in the process, hope that's ok with you.