Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Fixed docs indentation in rootScope.js #8963

Closed
wants to merge 1 commit into from

Conversation

Zizzamia
Copy link
Contributor

@Zizzamia Zizzamia commented Sep 5, 2014

No description provided.

@petebacondarwin petebacondarwin added this to the 1.3.0-rc.1 milestone Sep 7, 2014
@petebacondarwin
Copy link
Contributor

LGTM

@caitp
Copy link
Contributor

caitp commented Sep 7, 2014

Not LGTM --- I don't think this is the right fix for this :( Fixing the trimming behaviour in dgeni would make more sense. Otherwise the code looks really weird.

@caitp
Copy link
Contributor

caitp commented Sep 7, 2014

@petebacondarwin --- Why don't we pick out the leading whitespace from each line in each sample, and remove the length of the shortest one from each line which starts with it? It would take more time to process, but we'd get correct results without making the codebase look weird. Given that code snippets are typically not very long, it seems reasonable to me.

@petebacondarwin
Copy link
Contributor

@caitp - we do this already with jsdoc comments but I am sure there was some reason why it didn't work for code blocks. One, perhaps more attractive, solution is to leave the stars at the start of each line:

  /*
   * ```
   * someCode();
   * ```
   */

Since we strip off leading whitespace and stars.

I'll have a look at the dgeni code again.

@petebacondarwin
Copy link
Contributor

So I looked at the code again. If there is a dgeni template that uses nunjucks code or marked "tags" then their contents will have its indentation trimmed. E.g. only the underlined whitespace below will be trimmed:

{% code %}
____function doStuff() {
____  SomeCodeThatIsIndented();
____}
{% endcode %}

If there is an inline example, using <example> tag then each file will have its indentation trimmed. E.g. only the underlined whitespace will be trimmed:

<example>
   <file ...>
____<div>
____  Some file contents
____</div> 
  </file>
</example>

But at the moment the code blocks within markdown (indicated by ```) are not being trimmed since dgeni is not aware of them. They are passed straight through to the marked parser.

@petebacondarwin
Copy link
Contributor

Looks like there might be a hook in marked that can let us trim the code: https://github.com/chjj/marked#block-level-renderer-methods

@jeffbcross jeffbcross modified the milestones: 1.3.0-rc.1, 1.3.0-rc.2 Sep 9, 2014
petebacondarwin added a commit to angular/dgeni-packages that referenced this pull request Sep 15, 2014
The service will trim indentation from code before rendering, which fixes
angular/angular.js#8963
@petebacondarwin
Copy link
Contributor

Well it will be closed when PR #9093 lands.

@petebacondarwin
Copy link
Contributor

Now its landed!

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Sep 15, 2014
dgeni-packages 0.10.0-rc.5 has a fix for this problem, so this commit updates
to that version.
Adds a new e2e test to prove this is fixed.

Closes angular#8963
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants