packages/bundler/src/tools/sassdoc.js
function createMarkdownItem(item) {
  let str = '';

  if (!item.context) return '';

  let status = item.access === 'public' ? '✅' : '❌';

  if (item.deprecated || item.deprecated === '') {
    status += '⚠️';
  }

  // Name
  str += `\n\n### ${status}${createUniqueName(
    item.context.name,
    item.context.type
  )}`;

  // Description
  if (item.description) {
    str += `\n\n${item.description.trim()}`;
  }

  // Value (variables)
  if (item.context.value) {
    str += `

<details>
<summary>Source code</summary>

\`\`\`scss
$${item.context.name}: ${item.context.value};
\`\`\`
</details>`;
  }

  // Code (mixins)
  if (item.context.code) {
    let paramStr = '';

    if (item.parameter) {
      item.parameter.forEach(param => {
        if (paramStr) paramStr += `, `;
        paramStr += `$${param.name}`;
        if (param.default) paramStr += `: ${param.default}`;
      });
    }

    str += `

<details>
<summary>Source code</summary>

\`\`\`scss
@${item.context.type} ${item.context.name}(${paramStr}) {${item.context.code}}
\`\`\`
</details>`;
  }

  // Parameters
  if (item.parameter && item.parameter.length) {
    str += `

- **Parameters**:

| Name | Description | Type | Default value |
| --- | --- | --- | --- |`;

    item.parameter.forEach(param => {
      const paramType = param.type
        ? `\`${param.type.replace(/\|/g, `\\|`)}\``
        : '—';
      const paramDefault = param.default ? `\`${param.default}\`` : '—';

      const row = `\n| \`$${param.name}\` | ${param.description ||
        '—'} | ${paramType} | ${paramDefault} |`;

      str += row;
    });
  }

  // Example
  if (item.example && item.example.length) {
    str += `\n\n**Example**:`;

    if (item.example[0].description) {
      str += ` ${item.example[0].description}`;
    }

    str += `

<details>
<summary>Example code</summary>

\`\`\`${item.example[0].type}
${item.example[0].code}
\`\`\`
</details>`;
  }

  // Bullets
  const metadata = [];

  const groupName = createGroupName(item.group);

  metadata.push({
    key: 'Group',
    value: createAnchorLink(groupName, groupName),
  });

  if (item.return) {
    metadata.push({
      key: 'Returns',
      value: `\`${item.return.type}\` ${item.return.description || ''}`,
    });
  }

  if (item.type) {
    metadata.push({
      key: 'Type',
      value: `\`${item.type}\``,
    });
  }

  if (item.alias) {
    metadata.push({
      key: 'Alias',
      value: `\`${item.alias}\``,
    });
  }

  if (item.aliased) {
    let subbullets = '';

    item.aliased.forEach(aliased => {
      subbullets += `\n  - \`${aliased}\``;
    });

    metadata.push({
      key: 'Aliased',
      value: subbullets,
    });
  }

  if (item.content) {
    metadata.push({
      key: 'Content',
      value: item.content,
    });
  }

  if (item.require && item.require.length) {
    let subbullets = '';

    dedupeArray(item.require).forEach(requires => {
      subbullets += `\n   - ${createAnchorLink(
        `${requires.name} [${requires.type}]`,
        createUniqueName(requires.name, requires.type)
      )}`;
    });

    metadata.push({
      key: 'Requires',
      value: subbullets,
    });
  }

  if (item.usedBy && item.usedBy.length) {
    let subbullets = '';

    dedupeArray(item.usedBy).forEach(usedBy => {
      subbullets += `\n   - ${createAnchorLink(
        `${usedBy.context.name} [${usedBy.context.type}]`,
        createUniqueName(usedBy.context.name, usedBy.context.type)
      )}`;
    });

    metadata.push({
      key: 'Used by',
      value: subbullets,
    });
  }

  // if (item.since && item.since.length) {
  //   metadata.push({
  //     key: 'Since',
  //     value: item.since[0].version,
  //   });
  // }

  if (item.link && item.link.length) {
    let subbullets = '';

    item.link.forEach(link => {
      subbullets += `\n   - [${link.caption || 'Link'}](${link.url})`;
    });

    metadata.push({
      key: 'Links',
      value: subbullets,
    });
  }

  if (item.deprecated || item.deprecated === '') {
    metadata.push({
      key: 'Deprecated',
      value: item.deprecated || 'This may not be available in future releases',
    });
  }

  if (metadata.length) {
    str += '\n';

    metadata.forEach(meta => {
      str += `\n- **${meta.key}**: ${meta.value}`;
    });
  }

  return str;
}
function createMarkdownItem(item) {
  let str = '';

  if (!item.context) return '';

  let status = item.access === 'public' ? '✅' : '❌';

  if (item.deprecated || item.deprecated === '') {
    status += '⚠️';
  }

  // Name
  str += `\n\n### ${status}${createUniqueName(
    item.context.name,
    item.context.type
  )}`;

  // Description
  if (item.description) {
    str += `\n\n${item.description.trim()}`;
  }

  // Value (variables)
  if (item.context.value) {
    str += `

<details>
<summary>Source code</summary>

\`\`\`scss
$${item.context.name}: ${item.context.value};
\`\`\`
</details>`;
  }

  // Code (mixins)
  if (item.context.code) {
    let paramStr = '';

    if (item.parameter) {
      item.parameter.forEach(param => {
        if (paramStr) paramStr += `, `;
        paramStr += `$${param.name}`;
        if (param.default) paramStr += `: ${param.default}`;
      });
    }

    str += `

<details>
<summary>Source code</summary>

\`\`\`scss
@${item.context.type} ${item.context.name}(${paramStr}) {${item.context.code}}
\`\`\`
</details>`;
  }

  // Parameters
  if (item.parameter && item.parameter.length) {
    str += `

- **Parameters**:

| Name | Description | Type | Default value |
| --- | --- | --- | --- |`;

    item.parameter.forEach(param => {
      const paramType = param.type
        ? `\`${param.type.replace(/\|/g, `\\|`)}\``
        : '—';
      const paramDefault = param.default ? `\`${param.default}\`` : '—';

      const row = `\n| \`$${param.name}\` | ${param.description ||
        '—'} | ${paramType} | ${paramDefault} |`;

      str += row;
    });
  }

  // Example
  if (item.example && item.example.length) {
    str += `\n\n**Example**:`;

    if (item.example[0].description) {
      str += ` ${item.example[0].description}`;
    }

    str += `

<details>
<summary>Example code</summary>

\`\`\`${item.example[0].type}
${item.example[0].code}
\`\`\`
</details>`;
  }

  // Bullets
  const metadata = [];

  const groupName = createGroupName(item.group);

  metadata.push({
    key: 'Group',
    value: createAnchorLink(groupName, groupName),
  });

  if (item.return) {
    metadata.push({
      key: 'Returns',
      value: `\`${item.return.type}\` ${item.return.description || ''}`,
    });
  }

  if (item.type) {
    metadata.push({
      key: 'Type',
      value: `\`${item.type}\``,
    });
  }

  if (item.alias) {
    metadata.push({
      key: 'Alias',
      value: `\`${item.alias}\``,
    });
  }

  if (item.aliased) {
    let subbullets = '';

    item.aliased.forEach(aliased => {
      subbullets += `\n  - \`${aliased}\``;
    });

    metadata.push({
      key: 'Aliased',
      value: subbullets,
    });
  }

  if (item.content) {
    metadata.push({
      key: 'Content',
      value: item.content,
    });
  }

  if (item.require && item.require.length) {
    let subbullets = '';

    dedupeArray(item.require).forEach(requires => {
      subbullets += `\n   - ${createAnchorLink(
        `${requires.name} [${requires.type}]`,
        createUniqueName(requires.name, requires.type)
      )}`;
    });

    metadata.push({
      key: 'Requires',
      value: subbullets,
    });
  }

  if (item.usedBy && item.usedBy.length) {
    let subbullets = '';

    dedupeArray(item.usedBy).forEach(usedBy => {
      subbullets += `\n   - ${createAnchorLink(
        `${usedBy.context.name} [${usedBy.context.type}]`,
        createUniqueName(usedBy.context.name, usedBy.context.type)
      )}`;
    });

    metadata.push({
      key: 'Used by',
      value: subbullets,
    });
  }

  // if (item.since && item.since.length) {
  //   metadata.push({
  //     key: 'Since',
  //     value: item.since[0].version,
  //   });
  // }

  if (item.link && item.link.length) {
    let subbullets = '';

    item.link.forEach(link => {
      subbullets += `\n   - [${link.caption || 'Link'}](${link.url})`;
    });

    metadata.push({
      key: 'Links',
      value: subbullets,
    });
  }

  if (item.deprecated || item.deprecated === '') {
    metadata.push({
      key: 'Deprecated',
      value: item.deprecated || 'This may not be available in future releases',
    });
  }

  if (metadata.length) {
    str += '\n';

    metadata.forEach(meta => {
      str += `\n- **${meta.key}**: ${meta.value}`;
    });
  }

  return str;
}
Create markdown for Sassdoc item (function, mixin, placeholder, variable)
@param {string} item - Sassdoc item
@return {string} item in markdown formatting