Make documentation exportable importable

Created on 11 October 2023, about 1 year ago
Updated 27 October 2023, about 1 year ago

Problem/Motivation

One drawback of the content model documentation at this time is that a field or entity has to exist before it can be documented so it prevents documentation from riding along with the code that created the thing to document.

As a site developer it would be nice to be able to create a Content Model Document locally and then be able to export and initialize the import.

The import should not be a sync, only imported once, then maintained as content on the prod instance of Drupal.

Some possibilities:

  • Export with a copyable array that could then be pasted into a hook_update_N which would instantiate the document with the initial values. Drawback: this only solves the initial case of creating the document, not making changes to it as new code is released.
  • Tome sync
  • content import with some kind of import.
  • A migration from a csv or other data source? (would still need a way to export)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.0

Component

Content model document

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @swirt
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    This feature has been added.

    The module now has a built in system for exporting CM Documents from you local environment and having them import into your production site when your code deploys.

    Drush commands

    • Export: drush content-model-documentation:export <id>
    • Import:
      drush content-model-documentation:import '/alias/of/the/cm-document'
      

    hook_update_n()

        use Drupal\content_model_documentation\CmDocumentMover\CmDocumentImport;
    
        /**
         * Import some CM Documents.
        */
        function <local_module>_update_9017() {
          $cm_documents_to_import = [
            '/admin/structure/types/manage/promo_banner/document',
            '/admin/structure/types/manage/full_width_banner_alert/document',
          ];
          // If set to true, the hook_update calls itself a failure if any of the documents are rejected.  Setting to FALSE causes the hook_update to call itself complete even if a document(s) get rejected.
          $strict = TRUE;
          return CmDocumentImport::import($cm_documents_to_import, $strict);
        }
    
    
    See the module help page / readme for step by steps.
    
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    Went out with 1.0.21

Production build 0.71.5 2024