3 Commits

Author SHA1 Message Date
featherless
e1e6d249a4
[Docs] Add badges to all components. (#4278)
As part of our readme generator, components can now opt in to displaying badges in their readme.

The badges are generated from https://shields.io/ and are focused on an individual component. We're currently generating the following badges:

- Open bug count.
2018-05-25 11:12:48 -04:00
featherless
5019be81da
[scripts] Add support for API list generation and improve the script's messages. (#3672)
./scripts/generate_readme will now generate the Design & API documentation section if desired.

Adding the following snippet to docs/README.md will result in the design & API links section being generated. This section is auto-generated from the jazzy API output and includes all classes, protocols, and enumerations. These links were a pain in the butt to add and maintain before, and now we don't have to 🎉.

```
<!-- design-and-api -->
```

Also updated the docs docs accordingly.

Also changed the order of operations so that articles are expanded inline and then pretty lists are generated. This will ensure that articles with pretty lists also get prettified.

---

## Example input (in ActivityIndicator)

```
<!-- design-and-api -->
```

## Example output

<ul class="icon-list">
  <li class="icon-list-item icon-list-item--spec"><a href="https://material.io/go/design-progress-indicators">Material Design guidelines: Progress & Activity</a></li>
  <li class="icon-list-item icon-list-item--link">Class: <a href="https://material.io/components/ios/catalog/progress-indicators/activity-indicators/api-docs/Classes/MDCActivityIndicator.html">MDCActivityIndicator</a></li>
  <li class="icon-list-item icon-list-item--link">Class: <a href="https://material.io/components/ios/catalog/progress-indicators/activity-indicators/api-docs/Classes/MDCActivityIndicatorTransition.html">MDCActivityIndicatorTransition</a></li>
  <li class="icon-list-item icon-list-item--link">Protocol: <a href="https://material.io/components/ios/catalog/progress-indicators/activity-indicators/api-docs/Protocols/MDCActivityIndicatorDelegate.html">MDCActivityIndicatorDelegate</a></li>
  <li class="icon-list-item icon-list-item--link">Enumeration: <a href="https://material.io/components/ios/catalog/progress-indicators/activity-indicators/api-docs/Enums/MDCActivityIndicatorMode.html">MDCActivityIndicatorMode</a></li>
</ul>
2018-05-02 22:31:59 -04:00
featherless
18617943ab
[scripts] Implement a templatized readme generator. (#3601)
This PR adds a new script, `scripts/generate_readme`, which will generate a root README.md file for a component from the component's docs/ content.

The advantages of this script over our current process of writing readmes:

- Documentation articles can be broken out into separate files, making it easier to generate and apply templates.
- Our component readmes now have auto-generated table of contents.
- Our documentation can be written in plain markdown with minimal material.io html magic.
- Having docs in separate files doesn't result in multiple "component pages" on material.io - everything ends up in a single component document on the site. E.g. the "Color Theming" article no longer shows up as its own link on material.io.

Example usage:

```bash
./scripts/generate_readme ActivityIndicator
```

---

The script makes the following assumptions:

A component has the following directory structure:

```
components/
  Component/
    README.md <- The component's main readme.
                 This is the readme that will show up on material.io.
    docs/
      README.md       <- A skeletal readme with links to other docs files.
      some-article.md <- An article that may be linked to.
```

`components/Component/docs/README.md` is treated as a standard markdown file, with the additional interpretations:

```
* [Text](url)
Treated as an icon list for the material.io website.
If the url links to any go/design- url, the link will use the spec icon

- [Text](some-article.md)
Indicates that the linked article should be added verbatim to the main README.md

<!-- toc -->
A table of contents should be generated here.
```

The script then does the following:

1. Generates a template README from the component's .vars file.
2. Appends the component's docs/README.md to the readme.
3. Rewrites any asset and relative url paths.
4. Transforms all `* [text](link)`-formatted link lists into icon-list lists.
4b. If an icon list url points to a design site, the spec icon will be used for the list item.
5. Replaces every `- [text](link)`-formatted link list item with the contents of the file.
6. Generates a table of contents if `<!-- toc -->` is found. The table of contents will include all level 2 and 3 headers found after the toc tag.
7. Copies the output to the component's root README.md.

The implication of this script is that we can now write documentation as small files which are easier to templatize. These smaller files can be aggregated together into a single larger README.md that is consumable by the material.io website.

Example of table of contents on material.io:

<img width="460" alt="screen shot 2018-05-01 at 9 07 31 am" src="https://user-images.githubusercontent.com/45670/39473887-1fa6c85c-4d1f-11e8-8620-d6b151a315c6.png">
2018-05-01 14:24:29 -04:00