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

fix: Don't strip new lines in dhautofunction #805

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Sep 5, 2024

No longer removes newlines, residual from before we were using a table and they were messing with the formatting I believe

@jnumainville jnumainville self-assigned this Sep 5, 2024
@dsmmcken
Copy link
Contributor

dsmmcken commented Sep 5, 2024

That's not automatically going to fix it. HTML will ignore those new lines unless we preserve spaces.

You are already inserting it into the doc, which WILL preserve new lines as markdown.

I would just pull the description and returns parts from inside the and insert them directly above.

<insert description if exists> This will be treated as markdown here, so even links and stuff would work.

**Returns: ** <insert returns if exists>

<Paramtable withoth those two things/>

@jnumainville
Copy link
Collaborator Author

would that give you less control though if we wanted to change things?
and what about new lines within the parameters?

@dsmmcken
Copy link
Contributor

dsmmcken commented Sep 9, 2024

It's still under "our" control, so it would be fine.

Are new lines in the parameters valid docstrings?

@jnumainville
Copy link
Collaborator Author

I wasn't precise - it doesn't give less control overall, it splits a task into two parts, giving less control in the next step after this script.
I see this step as take code -> output processed data that can be used to build the presentation layer.
So doing part of the processing for the presentation layer is creating a poorer abstraction by mixing concerns, and if we want to change both the format of, for example, the returns block and the parameters table, that's now done in two different spots.
If there's something I can do to make the new lines easier to process in the presentation layer building, that makes sense, but ideally it's still data.

New lines in the docstring parameters are valid

@dsmmcken
Copy link
Contributor

dsmmcken commented Sep 9, 2024

That's the easiest way to get full md support in descriptions. You are inserting into the presentation layer.

inserting

{result.description}

*Returns:( {result.returns}

<ParamTable restults={results dict} />

doesn't seem that different to me.

and um. actually description and returns aren't params anyways.

@jnumainville
Copy link
Collaborator Author

jnumainville commented Sep 9, 2024

My point is, currently, ParamTable handles all of the actual presentation.
ParamTable is meaningless without the presentation layer.
The suggested change would make it so some presentation is handled here, some presentation is handled elsewhere.
You are right in that it isn't much different, but it is an architectural difference, and I don't think the optimal change to make, because it adds overall complexity to the boundary, even if "easier" to do now.
But, if that's the direction we want to go, it's what I'll do.

My concern about newlines in params still remains.
See this example to clarify (note that in the code I've got in this PR there is a subtle regex bug currently, but below is what the parameters will look like)
{"name": "by", "type": "str | list[str] | None", "description": "A column or list of columns that contain values to plot the figure traces by.\nAll values or combination of values map to a unique design. The variable\nby_vars specifies which design elements are used.\nThis is overriden if any specialized design variables such as color are specified", "default": "None"}

@dsmmcken
Copy link
Contributor

Embed it please. I acknowledge it's less ideal on your side. However it will be more performant on the front end as it avoids having the user waiting for it to be parsed.

sphinx_ext/make_docs_utilities.py Show resolved Hide resolved
sphinx_ext/deephaven_autodoc.py Outdated Show resolved Hide resolved
mofojed
mofojed previously approved these changes Sep 26, 2024
Comment on lines +311 to +318
return_description = result["return_description"]
return_type = result["return_type"]

autofunction_markdown = (
f"{AUTOFUNCTION_COMMENT_PREFIX}"
rf"{return_description}<br /><br />"
rf"**Returns:** {return_type}<br /><br />"
rf"<ParamTable param={{{dat}}} />"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these
actually inserted in output?"

If so, it's markdown, new lines are respected.

Also should this output be conditional? If no return type or no description?

Copy link
Contributor

Choose a reason for hiding this comment

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

image

I would expect output that looks more like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you mean \n are respected they are not at least in this case. This is inserting a raw string (which is has to do because otherwise sphinx tries to escape characters it shouldn't) so it writes a raw \n, it doesn't create a new line.

Currently return_type and return_description are required. This can change but will require a bit more rework than just here.

Copy link
Collaborator Author

@jnumainville jnumainville Sep 30, 2024

Choose a reason for hiding this comment

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

I'll see if I can replace those <br /> with a different sort of new line in the post processing, but ideally I don't want actual markdown new lines until then because it makes the processing harder than it needs to be

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done, that seems to have the needed output

@jnumainville jnumainville merged commit 0dd7aeb into deephaven:main Oct 15, 2024
24 checks passed
jnumainville added a commit that referenced this pull request Oct 17, 2024
)

Goes back to stripping newlines for type descriptions specifically
(changed in #805) as those don't parse properly now
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.

3 participants