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

Fixes for failing types #28

Merged
merged 4 commits into from
Nov 28, 2024
Merged

Fixes for failing types #28

merged 4 commits into from
Nov 28, 2024

Conversation

RobertoRoos
Copy link
Member

Resolves #26

@RobertoRoos RobertoRoos self-assigned this Nov 28, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.39%. Comparing base (c7d3749) to head (3932470).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #28      +/-   ##
==========================================
+ Coverage   83.65%   84.39%   +0.74%     
==========================================
  Files          10       10              
  Lines         734      737       +3     
==========================================
+ Hits          614      622       +8     
+ Misses        120      115       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RobertoRoos
Copy link
Member Author

@Philipp1297 are you in a position to test this branch on your project?

No worries if not, then I'll just merge it.

@Philipp1297
Copy link

@RobertoRoos Thank you for the quick fix. I will test this today

@Philipp1297
Copy link

Philipp1297 commented Nov 28, 2024

@RobertoRoos
I tested with my Project and it is failing on three code snippets:

TYPE T_INTERLOCK : WORD; 
END_TYPE

Corresponding Error Message: *Error parsing node T_INTERLOCK in file C:\Users\User\Desktop\GIT\TwinCAT2Doc\test_files\baselib\BaseLibProj\BaseLib\POUs\HMI\Datentypen\T_INTERLOCK.TcDUT
(None:1:20: Expected '//' or '(*(.|\n)*?*)' or '{' or 'STRUCT' or 'UNION' or '(' => 'TERLOCK : WORD; END')

{attribute 'qualified_only'}
{attribute 'strict'}
{attribute 'analysis' := '-32'}
TYPE E_HMI_BUTTON_FEEDBACK :
(
	NONE := 0,
	ACTIVE := 1,
	PENDING := 2,
	WARNING := 3,
	ERROR := 4
) INT := NONE;
END_TYPE

Corresponding Error Message: *Error parsing node E_HMI_BUTTON_FEEDBACK in file C:\Users\PhilippSchinacher\Desktop\GIT\TwinCAT2Doc\test_files\baselib\BaseLibProj\BaseLib\POUs\HMI\Enum\E_HMI_BUTTON_FEEDBACK.TcDUT
(None:11:7: Expected '\s' or ';' => '= 4 ) INT := NONE; E')

The third one was due to ; in string.

To make sure, I tested it with the right approach:

  • Switched to the grammer branch
  • git install . for local installation of the new version
  • changed the conf.py file

conf.py file content:

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "TestProject"
copyright = "2022, Robert Roos"
author = "Robert Roos"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["plcdoc", "sphinx.ext.autodoc"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

plc_project = "C:/Users/PhilippSchinacher/Desktop/GIT/TwinCAT2Doc/test_files/baselib/BaseLibProj/BaseLib/BaseLib.plcproj"


plc_sources = [
    # "../TwinCAT PLC/.TcPOU",
    "../../tests/plc_code/TwinCAT PLC/MyPLC/POUs/RegularFunction.TcPOU",
    "../../tests/plc_code/TwinCAT PLC/MyPLC/POUs/PlainFunctionBlock.TcPOU",
    "../../tests/plc_code/TwinCAT PLC/MyPLC/POUs/PlainFunction.TcPOU",
    "../../tests/plc_code/TwinCAT PLC/MyPLC/POUs/FB_MyBlock.TcPOU",
]

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
nitpicky = True

If you need more input or help, feel free to contact me.

@RobertoRoos
Copy link
Member Author

Thanks for trying. Based on the error you posted, Expected '//' or '(*(.|\n)*?*)' or '{' or 'STRUCT' or 'UNION' or '(' => 'TERLOCK : WORD; END', it really seems like Sphinx is not correctly using this branch.
The test cases I've added do resemble the code you've posted, and they succeed.

@Philipp1297
Copy link

You're correct—thank you for pointing that out. I tested with too many instances and got confused earlier. My apologies for the misunderstanding.

After running a proper test, the only issue that occurred was the string error. However, no documentation was generated.

I set the path to my TwinCAT project file in the examples/conf.py file and executed make clean followed by make html. Unfortunately, no .rst file corresponding to the PLC project was created.

Could this issue be related to the recent changes I made, or is there something wrong with my workflow?

I also ran pytest to ensure the tests were working, and they all passed successfully.

@RobertoRoos
Copy link
Member Author

Good to see you progress.

No .rest files would be generated with plcdoc. Like with Python's autodoc (and breathe, etc.) the content is read from code, but you'd still need .rst source files to produce content.
Consider the example under https://github.com/DEMCON/plcdoc/tree/master/examples/docs

@RobertoRoos RobertoRoos merged commit 8801ea1 into master Nov 28, 2024
6 checks passed
@RobertoRoos RobertoRoos deleted the bugfix/grammar branch November 28, 2024 15:25
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.

Error Parsing Custom Type Declaration
3 participants