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

Docs versioning test data #44471

Draft
wants to merge 7 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
post_title: How to add a custom field to simple and variable products
post_title: Updated - How to add a custom field to simple and variable products
menu_title: Add custom fields to products
tags: how-to
version: 8.8.0
---

In theory, this contains content specific to WooCommerce 8.7.0 or higher.

In this tutorial you will learn how to create a custom field for a product and show it in your store. Together we will set up the skeleton plugin, and learn about WP naming conventions and WooCommerce hooks. In the end, you will have a functioning plugin for adding a custom field.

The [full plugin code](https://github.com/EdithAllison/woo-product-custom-fields) was written based on WordPress 6.2 and WooCommerce 7.6.0
Expand Down
5 changes: 4 additions & 1 deletion docs/building-a-woo-store/configuring-caching-plugins.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
post_title: How to configure caching plugins for WooCommerce
post_title: Updated - How to configure caching plugins for WooCommerce
menu_title: Configure caching plugins
tags: how-to
version: 8.7.0
---

In theory, this contains content specific to WooCommerce 8.6.0 or higher.

## Excluding Pages from the Cache

Oftentimes if using caching plugins they'll already exclude these pages. Otherwise make sure you exclude the following pages from the cache through your caching systems respective settings.
Expand Down
9 changes: 4 additions & 5 deletions docs/contributing-docs/contributing-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Inside each subfolder you'll find various markdown files. When imported into the

## Getting Setup

> This guide presumes that you're familar with basic Git and GitHub functionality, that you're signed into a GitHub account, and that you have Git setup locally. If you're new to GitHub, we recommend reading their [quickstart](https://docs.github.com/en/get-started/quickstart/hello-world) and [working with forks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) guides before getting started.
> This guide presumes that you're familiar with basic Git and GitHub functionality, that you're signed into a GitHub account, and that you have Git setup locally. If you're new to GitHub, we recommend reading their [quickstart](https://docs.github.com/en/get-started/quickstart/hello-world) and [working with forks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) guides before getting started.

### Initial Setup

Expand All @@ -33,7 +33,7 @@ Inside each subfolder you'll find various markdown files. When imported into the
6. [Open a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) that merges your branch with the WooCommerce monorepo's trunk branch.
* To do this, when creating the pull request, set the `base repository` to `woocommerce/woocommerce`, the `base` to `trunk`, the `head repository` to `yourgithubusername/woocommerce` and the `compare` to the branch you created (eg: `docs/improve-extension-performance`).
* When creating the pull request, set a descriptive title. Additionally, ensure you fill out the template provided in the description. For purely docs changes, your testing instructions should reference any major changes you think should be checked.
7. The WooCommerce Developer Advocacy team will review your pull request and provide feedback via the comments as neccesary. Once the content is ready, we'll merge it into `trunk` and it'll appear on the Woo Developer Docs site!
7. The WooCommerce Developer Advocacy team will review your pull request and provide feedback via the comments as necessary. Once the content is ready, we'll merge it into `trunk` and it'll appear on the Woo Developer Docs site!

## Creating New Pages

Expand All @@ -59,6 +59,7 @@ Optionally, you can set additional metadata. The following fields are supported:
post_title: Your Post Title Goes Here
menu_title: Short Title Goes Here
tags: tag1, tag2, tag3
version: 9.9.0
---
```

Expand Down Expand Up @@ -111,11 +112,9 @@ The WooCommerce Developer Docs site pulls content from the monorepo using the [D
If you make any of the following changes, you must regenerate the docs manifest:

* You create, delete or move a file in the `docs/` folder
* You modify a page's Front Matter (eg: its title or tags)
* You modify a page's Front Matter (eg: its title or tags) or its content
* You create, rename or delete a category

You don't need to regenerate the manifest if you only make changes to a page's content.

### How to regenerate the manifest

These instructions presume you're currently have your `docs/` branch open and you've made your required changes to any files.
Expand Down
20 changes: 9 additions & 11 deletions docs/docs-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@
"id": "1629a329b1f4f1f24bba60f89e6f17c695b7ad0d"
},
{
"post_title": "How to configure caching plugins for WooCommerce",
"post_title": "Updated - How to configure caching plugins for WooCommerce",
"menu_title": "Configure caching plugins",
"tags": "how-to",
"version": "8.7.0",
"edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/building-a-woo-store/configuring-caching-plugins.md",
"hash": "5f0d999813ace7d5a9b2ae830d67b50c05806d87d1ba1cbb2d2c88a69aec1328",
"hash": "c6c766f47a68c254365c8ddb0fbb2d38d90da90f7d116596d8c23994ab69eedd",
"url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/building-a-woo-store/configuring-caching-plugins.md",
"id": "9f484f8db1111fa6c1b6108d40939c967eea7f47"
},
{
"post_title": "How to add a custom field to simple and variable products",
"post_title": "Updated - How to add a custom field to simple and variable products",
"menu_title": "Add custom fields to products",
"tags": "how-to",
"version": "8.8.0",
"edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/building-a-woo-store/adding-a-custom-field-to-variable-products.md",
"hash": "3f9ca41cf853de77b48bb8c2e762129f7dbeef8b7680471d2d55fe0c7b32a5cb",
"hash": "7cf040a242783dd4470c13310d42794b914437cf82d7a894ee57f6b93c32fa97",
"url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/building-a-woo-store/adding-a-custom-field-to-variable-products.md",
"id": "64b686dcd5fdd4842be2fc570108231d5a8bfc1b"
}
Expand Down Expand Up @@ -268,7 +270,7 @@
"post_title": "Contributing Technical Documentation",
"menu_title": "Contributing Docs",
"edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/contributing-docs/contributing-docs.md",
"hash": "3bcfb5ac1ad271b34f4f13db409b1f5e50c6ed6e310f474bcc3ccc2f4b0448b1",
"hash": "75e3aa0a30e9fe86c807e2765aec963a0a9636c530a49bd1e8e0d03f69d65515",
"url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/contributing-docs/contributing-docs.md",
"id": "71c1a72bfd4d5ae6aa656d4264b1bf3beb6eca1c"
}
Expand Down Expand Up @@ -916,11 +918,6 @@
],
"categories": []
},
{
"category_slug": "utilities",
"category_title": "Utilities",
"categories": []
},
{
"content": "\nThis section covers general guidelines, and best practices to follow in order to ensure your product experience aligns with WooCommerce for ease of use, seamless integration, and strong adoption.\n\nWe strongly recommend you review the current [WooCommerce setup experience](https://woo.com/documentation/plugins/woocommerce/getting-started/) to get familiar with the user experience and taxonomy.\n\nWe also recommend you review the [WordPress core guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/) to ensure your product isn't breaking any rules, and review [this helpful resource](https://woo.com/document/grammar-punctuation-style-guide/) on content style.\n\n## General\n\nUse existing WordPress/WooCommerce UI, built in components (text fields, checkboxes, etc) and existing menu structures.\n\nPlugins which draw on WordPress' core design aesthetic will benefit from future updates to this design as WordPress continues to evolve. If you need to make an exception for your product, be prepared to provide a valid use case.\n\n- [WordPress Components library](https://wordpress.github.io/gutenberg/?path=/story/docs-introduction--page)\n- [Figma for WordPress](https://make.wordpress.org/design/2018/11/19/figma-for-wordpress/) | ([WordPress Design Library Figma](https://www.figma.com/file/e4tLacmlPuZV47l7901FEs/WordPress-Design-Library))\n- [WooCommerce Component Library](https://woocommerce.github.io/woocommerce-admin/)\n",
"category_slug": "user-experience-extensions",
Expand Down Expand Up @@ -1209,5 +1206,6 @@
"categories": []
}
],
"hash": "a485b51014a2262571751ae495976ca40aa8ffd4fddc7ee8ca8171ee51bd8984"
"version": "8.8.0-dev",
"hash": "a61d8eef6eb58295d1723a4b681ea807d5c59c52f311e9a4cbf6c97f85da8f55"
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@
"react": "^17.0.2",
"react-resize-aware": "3.1.1"
}
},
"mddocs": {
"pattern": "Version: ([0-9]+\\.[0-9]+\\.[0-9]+.*)",
"source": "plugins/woocommerce/woocommerce.php"
}
}
2 changes: 1 addition & 1 deletion tools/monorepo-utils/dist/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const generatePostFrontMatter = (
'content',
'menu_title',
'tags',
'version',
];

const frontMatter = matter( fileContents, {
Expand Down
38 changes: 38 additions & 0 deletions tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,40 @@ function filenameMatches( filename: string, hayStack: string[] ) {
return found.length > 0;
}

function getManifestVersion() {
let versionString = '';
let packageData;

const packageFile = path.join( process.cwd(), 'package.json' );
if ( ! fs.existsSync( packageFile ) ) {
return versionString;
}

try {
const packageString = fs.readFileSync( packageFile, 'utf8' );
packageData = JSON.parse( packageString );
} catch ( error ) {
return versionString;
}

if ( ! packageData.mddocs || ! packageData.mddocs.source ) {
return versionString;
}

const versionFile = path.join( process.cwd(), packageData.mddocs.source );
if ( ! fs.existsSync( versionFile ) ) {
return versionString;
}

const versionData = fs.readFileSync( versionFile, 'utf-8' );
const versions = versionData.match( /Version: ([0-9]+\.[0-9]+\.[0-9]+.*)/ );
if ( versions.length > 1 ) {
versionString = versions[ 1 ];
}

return versionString;
}

async function processDirectory(
rootDirectory: string,
subDirectory: string,
Expand Down Expand Up @@ -164,6 +198,7 @@ export async function generateManifestFromDirectory(
.filter( ( item ) => item.substring( 0, 1 ) !== '#' );
}

const version = getManifestVersion();
const manifest = await processDirectory(
rootDirectory,
subDirectory,
Expand All @@ -174,6 +209,9 @@ export async function generateManifestFromDirectory(
ignoreList ?? [],
false
);
if ( version.length ) {
manifest.version = version;
}

// Generate hash of the manifest contents.
const hash = crypto
Expand Down