Code Monkey home page Code Monkey logo

changelog-parser's Introduction

changelog-parser

Yet another python changelog parser.

  • Loads data from a CHANGELOG.md file using code like:
    import changelog
    
    with open( "CHANGELOG.md", 'rb' ) as fp:
      changes = changelog.load( fp )
    or
    import changelog
    
    with open( "CHANGELOG.md", 'r' ) as fp:
      changes = changelog.loads( fp.read() )
  • Returns it in the following schema (some types are Python objects and not valid JSON schema):
    {
      "$schema": "https://json-schema.org/draft-07/schema#",
      "title": "Loaded Changelog",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version": {
            "oneOf": [ {
              "const": "Unreleased"
            }, {
              "type": "semver.Version",
              "description": "Python object from https://pypi.org/project/semver/"
            } ]
          },
          "date": {
            "oneOf": [ {
              "const": null
            }, {
              "type": "datetime.date",
              "description": "Python object from https://docs.python.org/3/library/datetime.html#date-objects; parsed using \"fromisoformat\""
            } ]
          },
          "yanked": {
            "type": "boolean"
          },
          "added": { "$ref": "#/$defs/change_list" },
          "changed": { "$ref": "#/$defs/change_list" },
          "depreciated": { "$ref": "#/$defs/change_list" },
          "removed": { "$ref": "#/$defs/change_list" },
          "fixed": { "$ref": "#/$defs/change_list" },
          "security": { "$ref": "#/$defs/change_list" },
          "compare_url": {
            "type": "string",
            "pattern": "^https?:\\/\\/.+"
          }
        },
        "required": [ "version", "date", "yanked" ],
        "additionalProperties": false
      },
      "$defs": {
        "change_list": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    }
  • Dumps data, structured like that above, to a CHANGELOG.md file using code like
    import changelog
    import semver
    from datetime import date
    
    with open( "CHANGELOG.md", 'rb' ) as fp:
      changes = changelog.load( fp )
    
    changes.insert( 0, {
       "version": semver.Version( major = 0, minor = 0, patch = 6 ),
       "date": date.today(),
       "added": [ "`dump` and `dumps` examples" ]
    } )
    
    with open( "CHANGELOG.md", 'wb' ) as fp:
      changelog.dump( changes, fp )
    or
    import changelog
    ...
    changelog_contents = changelog.dumps( changes )
    with open( "CHANGELOG.md", 'w' ) as fp:
      fp.write( changelog_contents )

changelog-parser's People

Contributors

jasonstiefel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.