Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Apr 19, 2021
2 parents 40dc4de + 31e3df0 commit 66b43d7
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 50 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
See the CHANGELOG.md
draft: false
prerelease: false
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

## Develop

## 1.3.0

- Added support for inline `/* */` comments

## v1.2.0

- Added `lwjson_find_ex` function to accept token pointer as starting reference
- Update of the docs for *find*
- Remove unused reset and add free function for future dynamic allocation support

## v1.1.0

- Improved find algorithm to match array index
- Added more test code

## v1.0.2

- Fix wrong parsing of hex in some corner cases
- Add more robust code to handle errorneous JSON input

## v1.0.1

- Added test code
- Fixed bug with improper string parsing

## v1.0.0

- First stable release
- Compliant with RFC 4627 for JSON
- Full features JSON parser
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Library provides generic JSON text parser.
* No recursion during parse operation
* Re-entrant functions
* Zero-copy, no ``malloc`` or ``free`` functions used
* Optional support for inline comments with `/* comment... */` syntax between any *blank* region of input string
* Advanced find algorithm for tokens
* Test coverage is available
* User friendly MIT license
Expand Down
4 changes: 2 additions & 2 deletions dev/VisualStudio/lwjson_dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.ActiveCfg = Debug|x64
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.Build.0 = Debug|x64
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.ActiveCfg = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.Build.0 = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x86.ActiveCfg = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x86.Build.0 = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Release|x64.ActiveCfg = Release|x64
Expand Down
4 changes: 3 additions & 1 deletion dev/VisualStudio/lwjson_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwJSON - Lightweight JSON format parser.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.2.0
* Version: v1.3.0
*/
#ifndef LWJSON_HDR_OPTS_H
#define LWJSON_HDR_OPTS_H
Expand All @@ -40,5 +40,7 @@
* Open "include/lwjson/lwjson_opt.h" and
* copy & replace here settings you want to change values
*/
#define LWJSON_CFG_JSON5 1
#define LWJSON_CFG_COMMENTS 1

#endif /* LWJSON_HDR_OPTS_H */
27 changes: 16 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,32 @@
copyright = '2020, Tilen MAJERLE'
author = 'Tilen MAJERLE'

# The full version, including alpha/beta/rc tags
version = 'v1.2.0'

# Try to get branch at which this is running
# and try to determine which version to display in sphinx
# Version is using git tag if on master or "latest-develop" if on develop branch
version = ''
git_branch = ''

# Get current branch
res = os.popen('git branch').read().strip()
for line in res.split("\n"):
if line[0] == '*':
git_branch = line[1:].strip()

# Decision for display version
try:
if git_branch.index('develop') >= 0:
version = "latest-develop"
except Exception:
print("Exception for index check")

# For debugging purpose
git_branch = git_branch.replace('(HEAD detached at ', '').replace(')', '')
if git_branch.find('master') >= 0 or git_branch.find('main') >= 0:
version = os.popen('git describe --tags --abbrev=0').read().strip()
if version == '':
version = 'v0.0.0'
elif git_branch.find('develop') != -1 and not (git_branch.find('develop-') >= 0 or git_branch.find('develop/') >= 0):
version = 'latest-develop'
else:
version = 'branch-' + git_branch

# For debugging purpose only
print("GIT BRANCH: " + git_branch)
print("VERSION: " + version)
print("GIT VERSION: " + version)

# -- General configuration ---------------------------------------------------

Expand Down
49 changes: 33 additions & 16 deletions docs/get-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
Getting started
===============

Getting started may be the most challenging part of every new library.
This guide is describing how to start with the library quickly and effectively

.. _download_library:

Download library
^^^^^^^^^^^^^^^^

Library is primarly hosted on `Github <https://github.com/MaJerle/lwjson>`_.

* Download latest release from `releases area <https://github.com/MaJerle/lwjson/releases>`_ on Github
* Clone `develop` branch for latest development
You can get it with:

* Downloading latest release from `releases area <https://github.com/MaJerle/lwjson/releases>`_ on Github
* Cloning ``master`` branch for latest stable version
* Cloning ``develop`` branch for latest development

Download from releases
**********************
Expand All @@ -24,7 +30,9 @@ Clone from Github
First-time clone
""""""""""""""""

* Download and install ``git`` if not already
This is used when you do not have yet local copy on your machine.

* Make sure ``git`` is installed.
* Open console and navigate to path in the system to clone repository to. Use command ``cd your_path``
* Clone repository with one of available ``3`` options

Expand All @@ -38,49 +46,58 @@ Update cloned to latest version
"""""""""""""""""""""""""""""""

* Open console and navigate to path in the system where your resources repository is. Use command ``cd your_path``
* Run ``git pull origin master --recurse-submodules`` command to pull latest changes and to fetch latest changes from submodules
* Run ``git pull origin master --recurse-submodules`` command to pull latest changes and to fetch latest changes from submodules on ``master`` branch
* Run ``git pull origin develop --recurse-submodules`` command to pull latest changes and to fetch latest changes from submodules on ``develop`` branch
* Run ``git submodule foreach git pull origin master`` to update & merge all submodules

.. note::
This is preferred option to use when you want to evaluate library and run prepared examples.
Repository consists of multiple submodules which can be automatically downloaded when cloning and pulling changes from root repository.
This is preferred option to use when you want to evaluate library and run prepared examples.
Repository consists of multiple submodules which can be automatically downloaded when cloning and pulling changes from root repository.

Add library to project
^^^^^^^^^^^^^^^^^^^^^^

At this point it is assumed that you have successfully download library, either cloned it or from releases page.
Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path

* Copy ``lwjson`` folder to your project
* Add ``lwjson/src/include`` folder to `include path` of your toolchain
* Add source files from ``lwjson/src/`` folder to toolchain build
* Copy ``lwjson`` folder to your project, it contains library files
* Add ``lwjson/src/include`` folder to `include path` of your toolchain. This is where `C/C++` compiler can find the files during compilation process. Usually using ``-I`` flag
* Add source files from ``lwjson/src/`` folder to toolchain build. These files are built by `C/C++` compiler
* Copy ``lwjson/src/include/lwjson/lwjson_opts_template.h`` to project folder and rename it to ``lwjson_opts.h``
* Build the project

Configuration file
^^^^^^^^^^^^^^^^^^

Configuration file is used to overwrite default settings defined for the essential use case.
Library comes with template config file, which can be modified according to needs.
This file shall be named ``lwjson_opts.h`` and its default template looks like the one below.
and it should be copied (or simply renamed in-place) and named ``lwjson_opts.h``

.. note::
Default configuration template file location: ``lwjson/src/include/lwjson/lwjson_opts_template.h``.
File must be renamed to ``lwjson_opts.h`` first and then copied to the project directory (or simply renamed in-place) where compiler
File must be renamed to ``lwjson_opts.h`` first and then copied to the project directory where compiler
include paths have access to it by using ``#include "lwjson_opts.h"``.

.. tip::
Check :ref:`api_lwjson_opt` section for possible configuration settings
List of configuration options are available in the :ref:`api_lwjson_opt` section.
If any option is about to be modified, it should be done in configuration file

.. literalinclude:: ../../lwjson/src/include/lwjson/lwjson_opts_template.h
:language: c
:linenos:
:caption: Template options file
:caption: Template configuration file

.. note::
If you prefer to avoid using configuration file, application must define
a global symbol ``LWJSON_IGNORE_USER_OPTS``, visible across entire application.
This can be achieved with ``-D`` compiler option.

Minimal example code
^^^^^^^^^^^^^^^^^^^^

Run below example to test and verify library
To verify proper library setup, minimal example has been prepared.
Run it in your main application file to verify its proper execution

.. literalinclude:: ../../examples/example_minimal.c
:language: c
:linenos:
:caption: Minimal example code
:caption: Absolute minimum example
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ Features
* No recursion during parse operation
* Re-entrant functions
* Zero-copy, no ``malloc`` or ``free`` functions used
* Optional support for inline comments with `/* comment... */` syntax between any *blank* region of input string
* Advanced find algorithm for tokens
* Testscoverage is available
* Tests coverage is available
* User friendly MIT license

Requirements
^^^^^^^^^^^^

* C compiler
* Few kB of ROM memory

Contribute
^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
breathe>=4.9.1
colorama
docutils>=0.14
sphinx>=2.0.1
docutils==0.16
sphinx>=3.5.1
sphinx_rtd_theme
sphinx-tabs
sphinxcontrib-svg2pdfconverter
Expand Down
4 changes: 2 additions & 2 deletions docs/user-manual/data-access.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Let's consider following JSON as input:
{
"brand":"Range",
"year":2020,
"crashed":1
"repainted":true
}
]
}
Expand Down Expand Up @@ -124,4 +124,4 @@ To retrieve full object of the array, application may only apply ``#[0.9]+`` in
as this is considered invalid path. To retrieve full array, pass path to array ``path.to.cars`` only, without trailling ``#``.

.. toctree::
:maxdepth: 2
:maxdepth: 2
5 changes: 2 additions & 3 deletions lwjson/src/include/lwjson/lwjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwJSON - Lightweight JSON format parser.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.2.0
* Version: v1.3.0
*/
#ifndef LWJSON_HDR_H
#define LWJSON_HDR_H
Expand Down Expand Up @@ -84,7 +84,6 @@ typedef LWJSON_CFG_INT_TYPE lwjson_int_t;
*/
typedef struct lwjson_token {
struct lwjson_token* next; /*!< Next token on a list */
struct lwjson_token* parent; /*!< Parent token (think about optimization and remove this one?) */
lwjson_type_t type; /*!< Token type */
const char* token_name; /*!< Token name (if exists) */
size_t token_name_len; /*!< Length of token name (this is needed to support const input strings to parse) */
Expand Down Expand Up @@ -185,7 +184,7 @@ lwjson_get_val_string(const lwjson_token_t* token, size_t* str_len) {
}

/**
* \brief Get length of string for \ref LWJSON_TOKEN_STRING token type
* \brief Get length of string for \ref LWJSON_TYPE_STRING token type
* \param[in] token: token with string type
* \return Length of string in units of bytes
*/
Expand Down
11 changes: 10 additions & 1 deletion lwjson/src/include/lwjson/lwjson_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwJSON - Lightweight JSON format parser.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.2.0
* Version: v1.3.0
*/
#ifndef LWJSON_HDR_OPT_H
#define LWJSON_HDR_OPT_H
Expand Down Expand Up @@ -72,6 +72,15 @@ extern "C" {
#define LWJSON_CFG_INT_TYPE long long
#endif

/**
* \brief Enables `1` or disables `0` support for inline comments
*
* Default set to `0` to be JSON compliant
*/
#ifndef LWJSON_CFG_COMMENTS
#define LWJSON_CFG_COMMENTS 0
#endif

/**
* \}
*/
Expand Down
2 changes: 1 addition & 1 deletion lwjson/src/include/lwjson/lwjson_opts_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwJSON - Lightweight JSON format parser.
*
* Author: Tilen MAJERLE <[email protected]>
* Version: v1.2.0
* Version: v1.3.0
*/
#ifndef LWJSON_HDR_OPTS_H
#define LWJSON_HDR_OPTS_H
Expand Down
Loading

0 comments on commit 66b43d7

Please sign in to comment.