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

Allow subsections and section less items #22

Merged
merged 8 commits into from
Dec 5, 2023
Merged

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented Dec 3, 2023

WHAT

🤖[deprecated] Generated by Copilot at 4a1d224

Added support for more flexible changelog formats. The Section type now has a SubSections property and can be empty. The Parser and ToMarkdown functions can handle changelogs with sub-sections and section-less entries. The tests were updated accordingly.

🤖[deprecated] Generated by Copilot at 4a1d224

Changelog gets richer
Section and Parser change
Autumn of refactor

🎁🛠️🧪

WHY

HOW

🤖[deprecated] Generated by Copilot at 4a1d224

  • Add Section type and SectionLessItems field to support sub-sections and section-less entries (link, link, link, link, link, link)
  • Modify ToMarkdown method to handle Section type and SectionLessItems field in markdown output (link, link)
  • Add pEntriesInASection function to parse items and sub-sections in a section (link)
  • Modify pCustomSection and pSection parsers to use pEntriesInASection function (link, link)
  • Add pSectionLessItems parser to parse entries that are not tied to any section (link, link)
  • Add test cases for sub-sections and section-less entries using FableSample and FableSectionLessSample values (link)

Oh hey @baronfel!
This is an attempt to make KAC work for the Fable changelogs.
They didn't fully play ball and have subsections or items without sections.
This PR aims to support those as well.

@nojaf
Copy link
Contributor Author

nojaf commented Dec 3, 2023

Tests do run on my Windows. Feels like a new line failure thing.

@baronfel
Copy link
Collaborator

baronfel commented Dec 4, 2023

The code looks good! If you can get it green I'd be happy to merge and re-release!

@MangelMaxime
Copy link
Contributor

I believe there is another direction possible to support Fable changelog and any changelog like the one from Nacara that are really detailed. #16

That direction is to consider Changelog as a header specification on top of Markdown. What I mean by that is that Changelog specs is to structure the header of the file which consist in:

  • Top level title (optional ?),
  • Optional description,
  • List of versions
    • List of categories
      • A markdown body

Example:

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## 2.0.0 - 2023-12-04

### Added

<!-- Markdown body -->

### Changed

<!-- Markdown body -->

## 1.0.0 - 2023-12-03

### Added

<!-- Markdown body  -->

The markdown body can be somehing as simple as:

* Item 1
* Item 2

or complex like:

#### JavaScript

* Item 1
* Item 2

#### All
* Layout system has been added

    User can add `layouts` node to `nacara.js`, it takes an object.

    Example:

    ```js
    {
        default: standard.Default,
        changelog: standard.Changelog
    }
    ```

The idea is that this will simplify the parser a lot because it will not depends on a specific structure.

Domains would looks like:

type ChangelogData =
    { 
        Added: string
        Changed: string
        Deprecated: string
        Removed: string 
        Fixed: string
        Security: string
        Custom: Map<string, string>
    }

type Release =
    {
        Version: SemanticVersion 
        Date: DateTime
        Categories: ChangelogData option
    }

type Changelog =
    {
        Title: string // option
        Description: string option
        Unreleased: ChangelogData option
        Releases: ChangelogData option
    }

@nojaf
Copy link
Contributor Author

nojaf commented Dec 4, 2023

Yeah maybe, it looks like

let mapChangelogData (data: ChangelogData) (item: ITaskItem) : ITaskItem =
item.SetMetadata("Added", stitch data.Added)
item.SetMetadata("Changed", stitch data.Changed)
item.SetMetadata("Deprecated", stitch data.Deprecated)
item.SetMetadata("Removed", stitch data.Removed)
item.SetMetadata("Fixed", stitch data.Fixed)
item.SetMetadata("Security", stitch data.Security)
for (KeyValue(heading, lines)) in data.Custom do
item.SetMetadata(heading, stitch lines)
item

is just combining items again as string.

@baronfel
Copy link
Collaborator

baronfel commented Dec 4, 2023

RE: @MangelMaxime's comments, I think that's a good direction to go for this library. The KAC 'spec' (such as it is) mentions no structure to the sections, just that there are sections. On the initial version of Ionide.KAC I probably over-corrected because the examples on the KAC website are mostly lists.

@nojaf
Copy link
Contributor Author

nojaf commented Dec 5, 2023

@baronfel this is ready. It can now parse all Fable changelog files.

Copy link
Collaborator

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

This LGTM, but before I merge @nojaf can you please validate if the change to use string interpolation breaks VS consumers?

@baronfel baronfel merged commit c015287 into ionide:main Dec 5, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants