Fix #117636: Update check file structure script for docs #117684

Merged
Brecht Van Lommel merged 7 commits from Prikshit-singh/blender:Update/check_file_structure into main 2024-02-02 18:59:20 +01:00
Contributor

Renamed file and made changes to function to handle markdown file and also added additional '-o'/'--output' argument to specify the file to write to.

Renamed file and made changes to function to handle markdown file and also added additional '-o'/'--output' argument to specify the file to write to.
Prikshit singh added 1 commit 2024-01-31 06:02:09 +01:00
Prikshit singh requested review from Brecht Van Lommel 2024-02-01 02:53:15 +01:00
Brecht Van Lommel requested changes 2024-02-01 11:36:26 +01:00
Brecht Van Lommel left a comment
Owner

It tried renaming some folders in source/blender to see if it would tell me about that, but it always says the markdown is up to date. Does it work for you?

It tried renaming some folders in `source/blender` to see if it would tell me about that, but it always says the markdown is up to date. Does it work for you?
@ -0,0 +8,4 @@
https://developer.blender.org/docs/features/code_layout/
It can run without any arguments, where it will download the MARKDOWN to Blender's source root:

MARKDOWN can be lowercase here and in other places.

MARKDOWN can be lowercase here and in other places.
brecht marked this conversation as resolved
@ -0,0 +10,4 @@
It can run without any arguments, where it will download the MARKDOWN to Blender's source root:
You may pass the markdown as an argument, e.g.

I would keep the "text" word, here and in other places.

I would keep the "text" word, here and in other places.
brecht marked this conversation as resolved
@ -0,0 +43,4 @@
return "\n{:s}\n{:s}\n".format(text, len(text) * underline)
def html_extract_markdown(data: str) -> Optional[str]:

This code is probably not needed at all anymore?

It was previous getting the raw wiki text from a textarea on a html page. But now we have a link to get the raw text directly.

This code is probably not needed at all anymore? It was previous getting the raw wiki text from a textarea on a html page. But now we have a link to get the raw text directly.
brecht marked this conversation as resolved
@ -0,0 +227,4 @@
default=os.path.join(SOURCE_DIR, "markdown_file_structure.txt"),
help="markdown file path, NOTE: this will be downloaded if not found!",
)
parser.add_argument(

I was confused, I think this is actually not needed at all since it really is the same thing as the -m option. I thought the script would write some fixed output, but actually it only tells you where the errors are.

So this option can be removed again.

I was confused, I think this is actually not needed at all since it really is the same thing as the `-m` option. I thought the script would write some fixed output, but actually it only tells you where the errors are. So this option can be removed again.
brecht marked this conversation as resolved
Author
Contributor

It tried renaming some folders in source/blender to see if it would tell me about that, but it always says the markdown is up to date. Does it work for you?

No actually 'wiki_to_paths_and_docstrings' was made to extract from html that's why its not able to detect, but I have changed the function, now its working. I wanted to know how does docstring looks like in markdown.

> It tried renaming some folders in `source/blender` to see if it would tell me about that, but it always says the markdown is up to date. Does it work for you? No actually 'wiki_to_paths_and_docstrings' was made to extract from html that's why its not able to detect, but I have changed the function, now its working. I wanted to know how does docstring looks like in markdown.
Author
Contributor

Also two files are mentioned in markdown which are not in Blender repo could you confirm:

Also two files are mentioned in markdown which are not in Blender repo could you confirm:

These folders were indeed renamed, and the code layout page should be updated for that.

I would not expect a Python error to happen because of that, it should be handled more gracefully.

These folders were indeed renamed, and the code layout page should be updated for that. I would not expect a Python error to happen because of that, it should be handled more gracefully.
Author
Contributor

I have handled that error wanted to ask you that it also shows this, Do need to fix my code for this one or this is also intended to happen:

I have handled that error wanted to ask you that it also shows this, Do need to fix my code for this one or this is also intended to happen:

That looks good. I guess you still need to push your updated code to this pull request?

That looks good. I guess you still need to push your updated code to this pull request?
Author
Contributor

Yes just wanted you confirmation on this

Yes just wanted you confirmation on this
Prikshit singh added 1 commit 2024-02-01 18:31:47 +01:00
Brecht Van Lommel requested changes 2024-02-01 18:42:34 +01:00
@ -0,0 +85,4 @@
def markdown_to_paths_and_docstrings(markdown: str) -> Tuple[List[str], List[str]]:
file_paths = []
file_paths_docstring = []

This code can be simplify if you remove these tags from the entire markdown text at the start.

markdown = markdown.replace("<p>", "")
markdown = markdown.replace("</p>", "")
markdown = markdown.replace("<strong>", "")
markdown = markdown.replace("</strong>", "")
markdown = markdown.replace("</td>", "")

Then all you need to check is that the line starts with <td markdown>/, and the rest of the line should be ok to test as a path.

This code can be simplify if you remove these tags from the entire markdown text at the start. ``` markdown = markdown.replace("<p>", "") markdown = markdown.replace("</p>", "") markdown = markdown.replace("<strong>", "") markdown = markdown.replace("</strong>", "") markdown = markdown.replace("</td>", "") ``` Then all you need to check is that the line starts with `<td markdown>/`, and the rest of the line should be ok to test as a path.
Author
Contributor

Thank you for the advice, wanted to ask how should I handle file_path_docstring.

Thank you for the advice, wanted to ask how should I handle file_path_docstring.
brecht marked this conversation as resolved
Prikshit singh added 1 commit 2024-02-02 12:17:15 +01:00
Author
Contributor

In the latest PR I Wanted to know what is the purpose of file_paths_docstring in markdown_to_paths_and_docstrings
what was it extracting in older file.

In the latest PR I Wanted to know what is the purpose of `file_paths_docstring` in markdown_to_paths_and_docstrings what was it extracting in older file.

It's about detecting TODO text in the description. But I don't think that's very useful, it's trivial to see by just looking at the page. So just remove the code for those docstrings.

It's about detecting TODO text in the description. But I don't think that's very useful, it's trivial to see by just looking at the page. So just remove the code for those docstrings.
Author
Contributor

sure anything else

sure anything else
Brecht Van Lommel requested changes 2024-02-02 12:34:23 +01:00
@ -0,0 +63,4 @@
def markdown_to_paths_and_docstrings(markdown: str) -> Tuple[List[str], List[str]]:
file_paths = []
file_paths_docstring = []
start_index=0

Remove this line, it's not needed.

Remove this line, it's not needed.
@ -0,0 +71,4 @@
markdown = markdown.replace("</td>", "")
lines = markdown.split("\n")
i = 0
while i < len(lines):

This code can be simplified to:

for line in markdown.splitlines():
This code can be simplified to: ``` for line in markdown.splitlines(): ```
@ -0,0 +73,4 @@
i = 0
while i < len(lines):
if lines[i].startswith("<td markdown>/"):
start_index=len("<td markdown>")

Follow code style with spaces around operators:

            start_index = len("<td markdown>") 
Follow code style with spaces around operators: ``` start_index = len("<td markdown>") ```
@ -0,0 +96,4 @@
def report_missing_source(file_paths: List[str]) -> int:
heading = "Missing in Source Dir"
test = [p for p in file_paths if not os.path.exists(os.path.join(SOURCE_DIR, p.lstrip("/")))]

Better to strip this / in markdown_to_paths_and_docstrings as it was doing before.

Better to strip this `/` in `markdown_to_paths_and_docstrings` as it was doing before.
brecht marked this conversation as resolved
@ -0,0 +123,4 @@
if not p.startswith("."):
p_abs = os.path.join(base_abs, p)
if os.path.isdir(p_abs):
p_rel = os.path.join(base, p+"/")

Also need spaces are + here, but if you strip this earlier as suggested, I guess this change is no longer needed.

Also need spaces are `+` here, but if you strip this earlier as suggested, I guess this change is no longer needed.
Prikshit singh added 1 commit 2024-02-02 13:24:44 +01:00
Prikshit singh added 1 commit 2024-02-02 13:29:23 +01:00
Prikshit singh requested review from Brecht Van Lommel 2024-02-02 17:23:20 +01:00
Brecht Van Lommel added 1 commit 2024-02-02 18:56:06 +01:00
Brecht Van Lommel added 1 commit 2024-02-02 18:56:57 +01:00
Brecht Van Lommel approved these changes 2024-02-02 18:57:44 +01:00
Brecht Van Lommel left a comment
Owner

Thanks, I found one more issue and fixed it.

Thanks, I found one more issue and fixed it.
Brecht Van Lommel merged commit 1159da5f36 into main 2024-02-02 18:59:20 +01:00
Brecht Van Lommel deleted branch Update/check_file_structure 2024-02-02 18:59:22 +01:00
Author
Contributor

Thank you, for putting your time into this PR.

Thank you, for putting your time into this PR.
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117684
No description provided.