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

Add documentation to pattern group and subgroup #1262

Closed
JosefBredereck opened this issue Oct 18, 2020 · 0 comments · Fixed by #1334
Closed

Add documentation to pattern group and subgroup #1262

JosefBredereck opened this issue Oct 18, 2020 · 0 comments · Fixed by #1334
Labels
pinned 📌 Don't let stalebot clean this up under consideration / design 🤔

Comments

@JosefBredereck
Copy link
Contributor

JosefBredereck commented Oct 18, 2020

In the code, the snipped at the end could be found. This behavior is not working as expected and will lead to issues following in our implementation. The intention was to document pattern groups and subgroups. We have no way to show this documentation, and also the group or subgroup will not be rendered when higher order documentation is available.

We will need a new approach to this special case.
First of all, we need to implement something similar to the pattern documentation but just for the groups and subgroups. Afterward, we need to implement a method to gather this data and place it in the correct position.

For not the code snipped will be removed in #1252 and can be implemented again.

// loadPattern.js : 55
const mp = require('./markdown_parser');
  const markdown_parser = new mp();
  if (fileObject.ext === '.md') {
    try {
      const proposedDirectory = path.resolve(
        patternlab.config.paths.source.patterns,
        fileObject.dir,
        fileObject.name
      );
      const proposedDirectoryStats = fs.statSync(proposedDirectory);
      if (proposedDirectoryStats.isDirectory()) {
        const subgroupMarkdownFileContents = fs.readFileSync(
          proposedDirectory + '.md',
          'utf8'
        );
        const subgroupMarkdown = markdown_parser.parse(
          subgroupMarkdownFileContents
        );
        const subgroupPattern = new Pattern(relPath, null, patternlab);
        subgroupPattern.patternSectionSubgroup = true;
        subgroupPattern.patternDesc = subgroupMarkdown
          ? subgroupMarkdown.markdown
          : '';
        subgroupPattern.flatPatternPath =
          subgroupPattern.flatPatternPath + '-' + subgroupPattern.fileName;
        subgroupPattern.isPattern = false;
        subgroupPattern.engine = null;
        patternlab.subgroupPatterns[
          subgroupPattern.patternPartial
        ] = subgroupPattern;

        return subgroupPattern;
      }
    } catch (err) {
      // no file exists, meaning it's a pattern markdown file
      if (err.code !== 'ENOENT') {
        logger.warning(err);
      }
    }
  }
mfranzke added a commit to mfranzke/patternlab-node that referenced this issue Jun 19, 2021
JosefBredereck pushed a commit that referenced this issue Jun 21, 2021
* feat(documentation): added (sub)groups documentation again #1262

* docs(patterndocumentation): added docs for how to do the pattern subgroups documentation

* chore(docs): added another small part

* chore(demo): added a subgroups demo file

* chore(docs): updated as requested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned 📌 Don't let stalebot clean this up under consideration / design 🤔
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant