Skip to content

Add documentation_starter to cookieplone-templates/templates #174

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

Merged
merged 54 commits into from
Apr 8, 2025

Conversation

ujsquared
Copy link
Contributor

@ujsquared ujsquared commented Mar 5, 2025

Fixes #7
Fixes plone/plone-sphinx-theme#3

Overview

This pull request introduces the documentation_addon template to the cookieplone-templates repository.
The template generates a Sphinx-based documentation environment for Plone projects, leveraging the latest plone-sphinx-theme from PyPI. It includes a comprehensive test suite to support both ongoing development and ensure reliable template generation.

Changes

There's loads of additions in this PR, so let's break it down:

Folder Structure

documentation_addon
├── {{cookiecutter.__folder_name}}
│   └── docs
│       ├── guides
│       ├── reference
│       └── _static
├── hooks
└── tests
  • {{cookiecutter.__folder_name}}/: The core template directory that becomes the generated project (e.g., collective.example.docs).

    • docs/: Contains Sphinx documentation files.
      • docs/guides/: Templated directory helping user structure their documentation using getting-started.md, usage.md etc.

      • docs/reference/: Includes technical reference docs (file-system-structure.md, index.md, theme-elements.md).

      • _static/: Static assets (favicon.ico, logo.svg) for branding.

  • hooks/: Contains post_gen_project.py for post-generation tasks (e.g., Git initialization). Can be used to add more hooks in the future for e.g. pre-generation hook.

  • tests/: Test suite with conftest.py and test_template.py for template validation.

  • Root Files: Essential project files (pyproject.toml, Makefile, README.md, etc.) for setup and building.

    • cookiecutter.json: Configuration file defining template variables and prompts.

    • Makefile: Top-level Makefile for mostly for running tests during development of documentation_addon.

Template Features

  • Plone Docs like Environment: Generates a ready-to-use Sphinx setup with conf.py, pre-configured for plone-sphinx-theme.

  • Dynamic Variables: Uses Jinja2 variables (e.g., {{ cookiecutter.title }}, {{ cookiecutter.__folder_name }}) for customization.

  • Git Support: Optional Git initialization via __documentation_addon_git_initialize toggle in cookiecutter.json.

To-do/Improvements

  • Check for buildout issue fix.
  • Better Documentation of the {{cookiecutter.__folder_name}}.
  • Integration with the A Plone project add-on option.
  • Add Towncrier? [Needs Discussion]

PS: currently, the build of generated documentation fails, due to a issue with buildout 🙁.

@ujsquared ujsquared changed the title Add documentation add-on to the arsenal of add-ons! Add documentation_addon to the arsenal of add-ons! Mar 5, 2025
@ujsquared ujsquared changed the title Add documentation_addon to the arsenal of add-ons! Add documentation_addon to the arsenal of add-ons! Mar 5, 2025
@stevepiercy
Copy link
Contributor

I am super excited by your work, @ujsquared! I have a lot on my plate at the moment, and hope to review this weekend. I've also requested reviews from people who I think would be interested in this add-on.

@ujsquared
Copy link
Contributor Author

I am super excited by your work, @ujsquared! I have a lot on my plate at the moment, and hope to review this weekend. I've also requested reviews from people who I think would be interested in this add-on.

No worries!

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

Is this an add-on?

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

you may want to create a cookuiecutter template for a documentation project with Sphinx theme Plone-Sphinx-Theme

@stevepiercy
Copy link
Contributor

@ksuess it's a cookieplone template that allows a person to generate docs for their project, without using sphinx-quickstart and already having PST and its extensions available.

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

Oops, typo. Should read cookiecutter template

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

Is this a Plone project or a Plone add-on?
If not, why should this be inxluded in a Plone rocket starter?

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

@stevepiercy
Copy link
Contributor

@ksuess I think you don't understand what this PR intends. It's not a Plone add-on. It's a Cookieplone template, similar to the backend and frontend. It generates a scaffold to create documentation for a Plone project generated from Cookieplone. Without it, a generated project does not have any documentation except for the default READMEs. Does that clarify?

@ksuess
Copy link
Member

ksuess commented Mar 6, 2025

Let's see how cookieplone evolves.

@sneridagh
Copy link
Member

sneridagh commented Mar 8, 2025

I'm also excited about this one. I myself was in the need of this:

  • Having an existing project, created with cookieplone, can I add easily now the boilerplate for the recommended documentation infrastructure?
  • Or, I am creating my project/add-on and I'd like to add from the beginning the documentation infrastructure.

But, I have questions to the current shape too. So, @ksuess is correct, it's nor a Volto add-on, nor a classicUI add-on. So call it add-on might lead to confusion since there's no such thing as a "documentation add-on".

Does it address the two things above? @ericof would cookieplone/cookiecutter allow this? I can recall you telling me that this was a limitation.

@ujsquared
Copy link
Contributor Author

  • Having an existing project, created with cookieplone, can I add easily now the boilerplate for the recommended documentation infrastructure?

Absolutely. This feature was proposed keeping in mind the idea of letting users to effortlessly create some form of documentation (based on plone-sphinx-theme) alongside their new plone app/add-on. All of this, using prompts to guide them in filling out the boilerplate details, should save the efforts and time to write documentation.

  • Or, I am creating my project/add-on and I'd like to add from the beginning the documentation infrastructure.

This feature hasn't been implemented. It's possible that we could add it by making changes here, but I'm not certain

But, I have questions to the current shape too. So, @ksuess is correct, it's nor a Volto add-on, nor a classicUI add-on. So call it add-on might lead to confusion since there's no such thing as a "documentation add-on".

To maintain consistency with the existing backend-addon and frontend-addon naming scheme in the code base, I named it documentation-addon. I think we can find better naming options.

@stevepiercy
Copy link
Contributor

Regarding the use of "_addon" in this template's name, it's reusing the patterns of frontend_addon and backend_addon without really thinking it through. I think renaming it to documentation_scaffold or similar would make more sense. documentation alone is an ambiguous name. Let's choose a good name before refactoring.

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started @ujsquared. I haven't done a detailed review of the template yet; I want to give some comments on the overall structure first.

First, I agree with the other comments that using addon in the name is wrong, because the thing it creates is not a Plone add-on. I would be okay with documentation_template or documentation_project as an alternative. (Or, open to other suggestions)

Currently this is set up to create a new repository that only contains documentation. That's usually not what we want. Usually documentation is a part of a repository that also includes something else (which could be any of the other main templates, i.e. a backend add-on, a frontend add-on, or a project that includes both frontend and backend).

I'd like to see this become a subtemplate that is called in the post_gen_project hook of the other templates to add a docs directory (if the user answered yes to a question about whether they want documentation). If it also works as a standalone template, that's fine, but the subtemplate is the main thing we want. (@stevepiercy, yell at me if I'm on the wrong track here.)

The files in the top level {{cookiecutter.__folder_name}} folder will be a problem because they would overwrite files from the other templates. I'd suggest that we move the Makefile and README into the docs folder (so users will need to cd into that folder before running docs commands). @stevepiercy would you be okay with that? The alternative is figuring out a way to construct a Makefile that includes commands from all the subtemplates which were used, which is possible (maybe using mxmake) but complicated.

@stevepiercy
Copy link
Contributor

First, I agree with the other comments that using addon in the name is wrong, because the thing it creates is not a Plone add-on. I would be okay with documentation_template or documentation_project as an alternative. (Or, open to other suggestions)

It's more of a foundation, platform, scaffold, base, or starter. It's not a project itself, but part of a project. Also since it's the result of being generated from a template, I don't want to reuse that term in its name.

I'd like to see this become a subtemplate that is called in the post_gen_project hook of the other templates to add a docs directory (if the user answered yes to a question about whether they want documentation). If it also works as a standalone template, that's fine, but the subtemplate is the main thing we want. (@stevepiercy, yell at me if I'm on the wrong track here.)

That's correct.

The files in the top level {{cookiecutter.__folder_name}} folder will be a problem because they would overwrite files from the other templates. I'd suggest that we move the Makefile and README into the docs folder (so users will need to cd into that folder before running docs commands). @stevepiercy would you be okay with that? The alternative is figuring out a way to construct a Makefile that includes commands from all the subtemplates which were used, which is possible (maybe using mxmake) but complicated.

Third option—and we did this in the unified Pyramid cookiecutter—include all possibilities, then delete those not selected. See https://github.com/Pylons/pyramid-cookiecutter-starter/blob/latest/hooks/post_gen_project.py.

@ujsquared ujsquared changed the title Add documentation_addon to the arsenal of add-ons! Add started_documentation to cookieplone-templates Mar 10, 2025
…:ujsquared/cookieplone-templates into feat/add-documentation-template
@ujsquared
Copy link
Contributor Author

ujsquared commented Apr 6, 2025

I'm all done! This looks really good.

Do you have any further changes @ujsquared?

Let's get one more pass from the Cookieplone experts before we merge.

@davisagli @ericof @sneridagh

Just rewriting the tests specific to documentation_starter. Otherwise, we are all clear.

It looks like there are quite a few CI check failures. For example:

https://github.com/ujsquared/cookieplone-templates/actions/runs/14290696715/job/40051498986

I have fixed most of these tests in the new commits. Final commits to be pushed in an hour or two.

@stevepiercy
Copy link
Contributor

Do we actually use templates/add-ons/documentation_starter/Makefile for testing?

@stevepiercy
Copy link
Contributor

@davisagli @ericof @sneridagh is it OK to merge this PR? We're getting ready for World Plone Day on Thu, Apr 10, and this PR is critical.

See Storybook build error in frontend functional tests: https://github.com/ujsquared/cookieplone-templates/actions/runs/14296375658/job/40064081218

@ujsquared
Copy link
Contributor Author

See Storybook build error in frontend functional tests: https://github.com/ujsquared/cookieplone-templates/actions/runs/14296375658/job/40064081218

I could reproduce this error on a volto-add-on created using the main branch too. The CI is somehow missing the storybook files. I could fuzzy find all *.mdx and *.storybook.@jsx/tsx files in core/ directory

@stevepiercy
Copy link
Contributor

@ujsquared @sneridagh is on it. See #189 (comment). We'll merge that PR before this one, and continue.

@stevepiercy stevepiercy requested review from davisagli and acsr April 7, 2025 09:48
@stevepiercy
Copy link
Contributor

@ujsquared @sneridagh fixed the image, and I updated the branch. Now we wait for tests to run. It should be green soon.

We need a review from not-Steve and not-Ujjwal before merging.

@stevepiercy
Copy link
Contributor

Watching closely: https://github.com/ujsquared/cookieplone-templates/actions/runs/14306067389/job/40090163130

@stevepiercy
Copy link
Contributor

I think the status checks are not reporting correctly because @ujsquared's PR comes from a fork, not this repo. Nonetheless, all the checks pass.

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

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

I tried it out and looked through the changes. Great work, @ujsquared and @stevepiercy!

I added some comments, but I think it's in a good place where we could go ahead and merge it and then do incremental improvements like normal.

Copy link
Member

Choose a reason for hiding this comment

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

This is not high priority, but it'd be nice to update this to be more similar to the Makefiles for the other templates. (For example, use a "generate" command instead of "bake", and make it run cookieplone instead of cookiecutter.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Per my earlier comment, I'm not clear for what this Makefile is used. Does Cookieplone call its targets during the generation process, for tests, or something else? It's not really documented anywhere.

Copy link
Member

Choose a reason for hiding this comment

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

On further inspection, I'm not sure either. I was thinking it was used by the github actions, but now I see they run commands from the top-level Makefile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly, the makefile is mostly borrowed over from plone-sphinx-theme. Hence the older cookie-cutter commands.

Copy link
Contributor

Choose a reason for hiding this comment

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

@stevepiercy stevepiercy requested a review from davisagli April 8, 2025 08:45
@stevepiercy
Copy link
Contributor

@ujsquared can you restart the failed job from your fork? I don't have access to do so.

https://github.com/ujsquared/cookieplone-templates/actions/runs/14329161498/job/40160975816

It failed due to a temporary PyPI outage.

@ujsquared
Copy link
Contributor Author

ujsquared commented Apr 8, 2025

@stevepiercy can you pls add your name to co-author

@ujsquared can you restart the failed job from your fork? I don't have access to do so.

https://github.com/ujsquared/cookieplone-templates/actions/runs/14329161498/job/40160975816

It failed due to a temporary PyPI outage.

It's still failing due to the outage.

@stevepiercy
Copy link
Contributor

@stevepiercy can you pls add your name to co-author

Done!

@ujsquared
Copy link
Contributor Author

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

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

I'm going to go ahead and merge.

@davisagli davisagli merged commit f7b4978 into plone:main Apr 8, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Plone Documentation Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Create plone-sphinx-theme documentation template Create cookiecutter
6 participants