Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Added split documentation from main repo #4

Merged

Conversation

GeeH
Copy link
Contributor

@GeeH GeeH commented Jun 12, 2015

This is just a first stab, but I have a script that can do this now - @weierophinney does this look right to you? I haven't tried rendering with Bookdown yet.

@GeeH
Copy link
Contributor Author

GeeH commented Jun 12, 2015

This renders now using Bookdown - it looks right to me @weierophinney.

@GeeH GeeH changed the title [WIP] Added split documentation from main repo Added split documentation from main repo Jun 12, 2015
@GeeH GeeH removed the WIP label Jun 12, 2015
@@ -0,0 +1 @@
{"title":"Zend\\Authentication","target":"html\/","content":["book\/zend.authentication.intro.md","book\/zend.authentication.adapter.dbtable.md","book\/zend.authentication.adapter.digest.md","book\/zend.authentication.adapter.http.md","book\/zend.authentication.adapter.ldap.md","book\/zend.authentication.validator.authentication.md"]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can u make this file more readable? Line breaks, indentation...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; we'll need to be able to edit it in order to insert or re-order pages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@weierophinney
Copy link
Member

@GeeH This is awesome!

Here's a list of general issues I see in the conversion:

  1. Notes are not formatted properly. The first line of the first paragraph receives the correct > prefix, but subsequent lines do not.

    Additionally, we need to come up with descriptive titles for the notes, and use actual headings (i.e., ###) for each.

  2. Bullet points. The correct prefix is used, but too many spaces are used between the delimiter and the first line of text. Additionally, lines are not flowed properly; they should be indented an additional 2 spaces, but are not.

  3. Many acronyms are using *ACRONYM* style notation; those can likely go when we edit.

  4. Inter-document linking does not translate betwee rst and markdown.

  5. A lot of examples are not following PSR-1/2. We should try and fix those if it's not too much effort.

  6. Bookdown.json should be human-readable, as it will be edited by humans in order to insert new pages or re-order pages.

My guess is that most of the formatting issues are due to the conversion from rst to markdown via pandoc. If so, we may be able to solve points 1, 2, and 5 by post-processing the results:

  1. We'd look for a line beginning with >, and check each following line; if the line is non-empty, we prefix it. For the first line, if the text matches /\*\*([^*]+)\*\*/, we change it to ### $1.
  2. We'd do a regex for ^(\s*)-\s+ and replace it with $1-. Similar to (1), we'd also check each following line, and if it's non-empty and does not start with whitespace or a -, we indent with $1.
  3. We can take the contents of a PHP fenced code block and run it through php-cs-fixer or phpcbf, and then re-inject the results into the block.

Point 3 we might be able to handle via regex: s/\*([A-Z-_]+)\*/$1/, but we'll need to spot-check.

Point 4 will be harder. I'm not entirely sure how we'll handle it, to be honest, until we start building the master manual. We could potentially link these to where the markdown files will live in each repo, however: eg., [Zend\Ldap](https://github.com/zendframework/zend-ldap/blob/master/doc/book/zend.ldap.md). If we go this route, we might be able to pre-process the file to change those links.

As for 6, pass it through jq and dump the results. :)

@GeeH
Copy link
Contributor Author

GeeH commented Jun 12, 2015

Agreed, I'll look at modifying the script for 1,2 and 5 tomorrow and resubmit.

@GeeH
Copy link
Contributor Author

GeeH commented Jun 12, 2015

Script now adds human readable JSON - thanks @danizord

@GeeH
Copy link
Contributor Author

GeeH commented Jun 13, 2015

  1. Fixed
  2. Fixed
  3. I think we need to raise issues for each repo to say "fix acronyms in this format and make them sane" then hope people create the PR to fix them
  4. I don't actually know what we need to do here. Again, I think we should raise standard issues in the docs to fix this by eye but not until we have relative urls for when the docs are rendered. I propose we ignore for now
  5. Working on it
  6. Fixed

@GeeH
Copy link
Contributor Author

GeeH commented Jun 15, 2015

I've done 5 to the best of my ability.

@weierophinney - what do you think about 3 and 4 please?

@weierophinney
Copy link
Member

@GeeH Looks great!

I agree with your assessment of my third point:

I think we need to raise issues for each repo to say "fix acronyms in this format and make them sane" then hope people create the PR to fix them

I also think this applies to 5 (as you and I determined that most of the formatting problems are not handled by either php-cs-fixer or phpcbf at this time).

As for 4, I agree. However, I'd like to do the following:

  • Pre-process such links to become normal markdown link syntax.
  • Raise an issue in the repo to fix those links once the docs for the relevant components are created.

I think this will ensure we can get them fixed well in the future. Since they follow a standard syntax, you should be able to pre-process them easily:

$contents = preg_replace('/:ref:`(?P<text>[^<]+)<(?P<link>[^>]+)>`/s', '[$1]($2)', $contents);

@GeeH
Copy link
Contributor Author

GeeH commented Jun 15, 2015

Roger that... on it.

@GeeH
Copy link
Contributor Author

GeeH commented Jun 15, 2015

Damn you to Hades with your pre processing

@GeeH
Copy link
Contributor Author

GeeH commented Jun 15, 2015

Ok, that's now done @weierophinney - what's next?

`Zend\Authentication\AuthenticationService::authenticate()` stores the identity from the
authentication result into persistent storage. Unless specified otherwise,
`Zend\Authentication\AuthenticationService` uses a storage class named
`Zend\Authentication\Storage\Session`, which, in turn, uses [Zend\\Session ](zend.session). A custom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crap. Looks like we need to adjust the PCRE to:

$docs = preg_replace('/:ref:`(.*?) <([^>]+)>`/', '[$1]($2)', $docs);

(links have the sequence <; previous regex wasn't taking into account the whitespace before the <, which leads to extra whitespace inside the link text).

@weierophinney
Copy link
Member

Ok, that's now done @weierophinney - what's next?

Once the regex is corrected for the links and you're re-run and pushed, I'll merge this. Then it's a matter of moving on to the next repos. :)

@GeeH
Copy link
Contributor Author

GeeH commented Jun 15, 2015

Looking better 😎

@weierophinney weierophinney added this to the 2.5.2 milestone Jun 15, 2015
@weierophinney weierophinney merged commit 80fe78a into zendframework:master Jun 15, 2015
weierophinney added a commit that referenced this pull request Jun 15, 2015
Added split documentation from main repo
weierophinney added a commit that referenced this pull request Jun 15, 2015
weierophinney added a commit that referenced this pull request Jun 15, 2015
weierophinney added a commit that referenced this pull request Jun 15, 2015
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.

3 participants