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

Refactoring/13 documentation and formatting #30

Merged
merged 29 commits into from
Sep 2, 2024

Conversation

MobiTikula
Copy link
Collaborator

@MobiTikula MobiTikula commented Aug 14, 2024

This PR has a goal to add to the project:

  • method documentation
  • module documentation
  • class documentation
  • poetry for environment management
  • black format tool and script formatting

Closes #13

@MobiTikula MobiTikula added the refactoring Improving code quality, paying off tech debt, aligning APIs label Aug 14, 2024
@MobiTikula MobiTikula self-assigned this Aug 14, 2024
@MobiTikula MobiTikula changed the base branch from master to refactoring/23-Introduce-code-format-check-and-linter-check August 14, 2024 15:46
@MobiTikula MobiTikula linked an issue Aug 14, 2024 that may be closed by this pull request
Copy link
Collaborator

@miroslavpojer miroslavpojer left a comment

Choose a reason for hiding this comment

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

  • pull

  • run

  • code review

  • I would propose creation of python project team format rules in cps-hadnbook.

  • I am missing mentioned black-poetry output.

main.py Outdated Show resolved Hide resolved
living_documentation_generator/generator.py Outdated Show resolved Hide resolved
living_documentation_generator/generator.py Outdated Show resolved Hide resolved
living_documentation_generator/generator.py Outdated Show resolved Hide resolved
living_documentation_generator/generator.py Outdated Show resolved Hide resolved
living_documentation_generator/github_projects.py Outdated Show resolved Hide resolved
living_documentation_generator/model/project_issue.py Outdated Show resolved Hide resolved
living_documentation_generator/model/project_status.py Outdated Show resolved Hide resolved
living_documentation_generator/utils/decorators.py Outdated Show resolved Hide resolved
living_documentation_generator/utils/utils.py Outdated Show resolved Hide resolved
__repositories (list[ConfigRepository]): List of config repositories to fetch from.
__project_state_mining_enabled (bool): Switch indicating if project state mining is enabled.
__output_path (str): The directory where the markdown pages will be stored.
"""

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

ISSUE_PAGE_TEMPLATE_FILE = os.path.join(PROJECT_ROOT, "..", "templates", "issue_detail_page_template.md")
Copy link
Collaborator

Choose a reason for hiding this comment

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

considering using os.pardir instead of ".."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great advice, change implemented in: 5db1778

A class representing the Living Documentation Generator.

Attributes:
__github_instance (GitHub): The GitHub instance used for authentication and requests.
Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps it's a bit redundant to have the attributes documented here and then also individually below. I'd just probably have the ones below, on the 'function' level

Copy link
Collaborator

Choose a reason for hiding this comment

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

also documenting types is redundant if you are using typing :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This comment led us into a conversation about the doc in all of our future QA projects, where agreed on some rules, that we will follow. All the documentation is updated.

issue_page_detail_template = f.read()

with open(LivingDocumentationGenerator.INDEX_PAGE_TEMPLATE_FILE, 'r', encoding='utf-8') as f:
with open(LivingDocumentationGenerator.INDEX_PAGE_TEMPLATE_FILE, "r", encoding="utf-8") as f:
Copy link
Collaborator

Choose a reason for hiding this comment

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

regarding these 2 with statements: what if the file was not opened successfully for whatever reason? Then issue_page_detail_template and issue_index_page_template wouldn't be available and the program would crash. Perhaps consider to either move operations working with them into the individual with scope, or initialize the variable above as None

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Logic was updated at: 5db1778

" Linked to project | Project status | Issue URL |\n"
"|-------------------|-----------------|------------------------|"
"-------------------|----------------|-----------|\n")
issue_table = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd consider extracting this to some constants.py or at least on top of the file as global constant perhaps - it's good to have visibility over these things

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue tables for index page are now moved into constants.py file (5db1778).

Copy link
Collaborator

@lsulak lsulak left a comment

Choose a reason for hiding this comment

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

Note: I only reviewed the generator.py

I quite like the way you progressed in Python!! Now, the next evolution of your engineering skills can be to try some testing exercises. Maybe even, when / if that makes sense, to try TDD (Test Driven Development - be careful, this is not a silver bullet in my opinion, but can be incredibly handy sometimes :) )

The point is, to cover some of the logic you wrote with unit tests - it actually is a 'documentation' for the 'usage' I would say, beyond just testing. Some people on my team are actually reading tests first, when reviewing someone else's PRs, so that they have good understanding on inputs and outputs and/or side effects of a given functionality, and that helps massively.

But good work, I like how it can be read from top to bottom almost like a book (so like in the book, you open it and tehre is table of content - in your case, method generate that implements nothing, but only calls high level operations, and then you go to individual operations - chapters of the book, for more details), there is a proper logging, documentation, typing, relatively good responsibility levels & sizes of functions :) keep up with good work

Base automatically changed from refactoring/23-Introduce-code-format-check-and-linter-check to master August 28, 2024 08:12
@MobiTikula
Copy link
Collaborator Author

Release notes

  • method documentation
  • module documentation
  • class documentation
  • implementing Black format tool
  • all python code formatted
  • README.md updated with using new tools

@MobiTikula
Copy link
Collaborator Author

Poetry was not implemented to the POC and is moved into separate SPIKE issue.

@miroslavpojer
Copy link
Collaborator

Poetry was not implemented to the POC and is moved into separate SPIKE issue.

Place here a link to issue, please.

Copy link
Collaborator

@miroslavpojer miroslavpojer left a comment

Choose a reason for hiding this comment

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

  • pull
  • code review
  • run

You have done excellent work here.

I may have one idea.

  • Are we expecting the code ready for review to be "blacked" already? I mean, would black not report any change in any file?
  • If the previous bullet is valid. We can prepare a CI check action, which will try to run black again and check if there were some changes in the code. If done, we can report a problem.

get_action_input,
make_absolute_path,
)
from living_documentation_generator.utils.utils import get_action_input, make_absolute_path
Copy link
Collaborator

Choose a reason for hiding this comment

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

From how many import items are required ()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whenever line is more than 120 char. The rules are still same. BUT If we talking about for example constants, which can increase during the time, I also think is alright to put them under each other. Black way of formatting is to reduce as many extra lines as possible. But it won't change your code, if you choose to put just two of your imports under each other.

@MobiTikula
Copy link
Collaborator Author

MobiTikula commented Sep 2, 2024

Poetry was not implemented to the POC and is moved into separate SPIKE issue.

Place here a link to issue, please.

Here is the link for the SPIKE issue #32.

@MobiTikula
Copy link
Collaborator Author

  • pull
  • code review
  • run

You have done excellent work here.

I may have one idea.

  • Are we expecting the code ready for review to be "blacked" already? I mean, would black not report any change in any file?
  • If the previous bullet is valid. We can prepare a CI check action, which will try to run black again and check if there were some changes in the code. If done, we can report a problem.

I also had that idea to implement Black as a CI workflow. With few adjustments we can make it real! With this workflow, we can make sure that all versions of projects have the same format.

- name: Check code format with Black
id: check-format
run: |
black --check $(git ls-files '*.py')
Copy link
Collaborator

Choose a reason for hiding this comment

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

why it is here also? It's duplicated, perhaps it's enough if black step is in the job analysis and then you can remove code-format-check completely - unless there is a good reason for its existence?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This block of code was not supposed to be there twice. Our idea is to have black tool as separate workflow, since it has different goal than pylint. Changed in: fdafc07.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was my idea. There are two possible reasons for job failure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok then, as the duplication was removed now, I'll approve as there is nothing else at the moment :) GJ!

README.md Outdated
```

## Run Black Tool Locally
This project uses the Black tool for code formatting.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This project uses the Black tool for code formatting.
This project uses the [Black](https://github.com/psf/black) tool for code formatting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change as well as for Pylint tool: fdafc07

Copy link
Collaborator

@miroslavpojer miroslavpojer left a comment

Choose a reason for hiding this comment

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

I see no more "problems".

- name: Check code format with Black
id: check-format
run: |
black --check $(git ls-files '*.py')
Copy link
Collaborator

Choose a reason for hiding this comment

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

It was my idea. There are two possible reasons for job failure.

@MobiTikula MobiTikula merged commit d2249ea into master Sep 2, 2024
4 checks passed
@MobiTikula MobiTikula deleted the refactoring/13-Documentation-and-formatting branch September 2, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improving code quality, paying off tech debt, aligning APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring - Documentation and formatting
3 participants