Skip to content

Proposal: include code examples for other languages #4634

@frankieroberto

Description

@frankieroberto

Context

The GOV.UK Design System website has always included code examples in both HTML and Nunjucks. However, whilst Nunjucks is used by the GOV.UK Prototype Kit, very few services use it in production. Instead, most services use a different language or framework, and either generate the HTML manually, or rely upon a 'port' of the Nunjucks components into their framework.

Some of these 'ports' have now been well-maintained over several years, have complete coverage of all components, and are used by dozens of services across multiple government departments.

Including code examples for these languages could help with several objectives:

  • improve the accessibility and usability of services by bringing the technical examples on how to use the components in a language together with the wider guidance on them
  • improve discoverability of the ports, so that teams do not accidentally duplicate work by starting a new one for the same language from scratch
  • bring more developers to the GOV.UK Design System website, helping to reduce perception of it being purely a design resource
  • reduce the need for teams to maintain separate websites detailing how to use each of the components in a particular framework, which can end up either skipping the guidance or duplicating content

How it could work

The GOV.UK Design System team could decide some criteria for which ports should be included in this way. The criteria could include things like:

  1. having been maintained for over x years
  2. used in production by over y services from at least z organisations
  3. at least xx% of components included

Once these criteria are met, the team maintaining the port could contribute the code examples for each component example, making sure that the example generates the same HTML as the existing example.

The examples could then be shown using additional tab links under the examples:

Image

Clicking on them would reveal the code, as well some text making clear that the example uses a port maintained by a different team or community:

Image

In addition, there could be some mention of the ports on the Production page - however any detailed guidance on how to install and set up the port could still be hosted elsewhere, either on a separate website or the README for that port on GitHub.

As an initial trial, the first port added in this way could be the Ruby on Rails port - see pull request #3538

Alternatives

The alternative would likely be for ports to maintain parallel websites detailing how to use each component, and for these to be only linked to from the Community resources page.

Another possibility is for the core GOV.UK Design System team to take on ownership of some of the existing ports (or create new ones). However this would likely require additional resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions