-
Notifications
You must be signed in to change notification settings - Fork 0
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
Default value for action parameters in TypeDoc #3
Comments
It may be eventually reduced from this: const base64Encode = (
{
encodeMode = 'Encode',
lineBreakMode = 'Every 76 Characters',
}: {
/** The encoding mode to use */
encodeMode?: WFEncodeMode,
/** The line break mode to use */
lineBreakMode?: WFSerialization | WFBase64LineBreakMode,
},
): WFWorkflowAction => ({
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode',
WFWorkflowActionParameters: {
WFEncodeMode: encodeMode,
WFBase64LineBreakMode: lineBreakMode,
},
}); to this: const base64Encode = ({
encodeMode = 'Encode',
lineBreakMode = 'Every 76 Characters',
}: {
/** The encoding mode to use */
encodeMode?: WFEncodeMode,
/** The line break mode to use */
lineBreakMode?: WFSerialization | WFBase64LineBreakMode,
}): WFWorkflowAction => ({
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode',
WFWorkflowActionParameters: {
WFEncodeMode: encodeMode,
WFBase64LineBreakMode: lineBreakMode,
},
}); but it's just aesthetics.
Thank you, it would be very welcome. There should be a few more edits to do, if I remember correctly, regarding the function names (joshfarrant#26):
I have an unrelated question: should the TypeDoc generated html page remain, or do we have to provide a completely custom React-based "API page"? I'm asking this because of the |
I think the end-goal would be to have custom docs which remove the need for the generated typedoc docs altogether, if that works for you? I'm just looking at converting the default params to the new format, currently my complete import { withActionOutput } from '../utils';
import Variable from '../interfaces/Variable';
import WFBase64LineBreakMode from '../interfaces/WF/WFBase64LineBreakMode';
import WFEncodeMode from '../interfaces/WF/WFEncodeMode';
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction';
/**
* Encodes or decodes text or files using Base64 encoding.
*
* ```js
* base64Encode({
* encodeMode: 'Encode',
* lineBreakMode: 'Every 76 Characters',
* });
* ```
*
* @action Base 64 Encode
* @section Actions/Scripting/Files
*/
const base64Encode = (
{
encodeMode = 'Encode',
lineBreakMode = 'Every 76 Characters',
}: {
/** The encoding mode to use */
encodeMode?: WFEncodeMode,
/** The line break mode to use */
lineBreakMode?: Variable | WFBase64LineBreakMode,
},
): WFWorkflowAction => ({
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode',
WFWorkflowActionParameters: {
WFEncodeMode: encodeMode,
WFBase64LineBreakMode: lineBreakMode,
},
});
export default withActionOutput(base64Encode);
export const icon = 70; Other than the default params, is there anything else you'd like me to change whilst going through the files at the same time @xAlien95? I'm making these changes from my |
Great. You can add the As for the sections, I used
My parser does a import { withActionOutput } from '../utils';
import WFBase64LineBreakMode from '../interfaces/WF/WFBase64LineBreakMode';
import WFEncodeMode from '../interfaces/WF/WFEncodeMode';
import WFSerialization from '../interfaces/WF/WFSerialization';
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction';
/**
* Encodes or decodes text or files using Base64 encoding.
*
* ```js
* base64Encode({
* encodeMode: 'Encode',
* lineBreakMode: 'Every 76 Characters',
* });
*
* @action Base64 Encode
* @section Actions > Scripting > Files
* @icon Scripting
* ```
*/
const base64Encode = (
{
/** The encoding mode to use */
encodeMode = 'Encode',
/** The line break mode to use */
lineBreakMode = 'Every 76 Characters',
}: {
encodeMode?: WFEncodeMode,
lineBreakMode?: Variable | WFBase64LineBreakMode,
},
): WFWorkflowAction => ({
WFWorkflowActionIdentifier: 'is.workflow.actions.base64encode',
WFWorkflowActionParameters: {
WFEncodeMode: encodeMode,
WFBase64LineBreakMode: lineBreakMode,
},
});
export default withActionOutput(base64Encode); I think that it's better to make these changes on the Essentially, what needs to be done is the following:
EDIT: in the last commit I added the Lightroom app icon, since now its action has come back in Shortcuts. You should edit joshfarrant#6 and add it back. |
The Next, I'll move on to destructuring the |
Cool @joshfarrant! I noticed you didn't use the gist I provided (https://gist.github.com/xAlien95/2f4faa8413b30039ed591f550a6a4b20) in my previous comment. It has all the icon names and a representation of all the sections. Using that you'll come with the right sections.
I filed a bug on TypeDoc (TypeStrong/typedoc#957) and provided a solution. Without my solution, referenced types won't work in the output json and comments have to be added this way: const createAlarm = (
{
/** The alarm active state */
active = true,
/** The alarm time */
time = '',
/** Whether the alarm should repeat on certain days */
repeat = [],
}: {
active?: boolean | Switch,
time?: string,
repeat?: Frequency[],
},
): string => {...}; With my fix, comments should be added this way: const createAlarm = (
{
active = true,
time = '',
repeat = [],
}: {
/** The alarm active state */
active?: boolean | Switch,
/** The alarm time */
time?: string,
/** Whether the alarm should repeat on certain days */
repeat?: Frequency[],
},
): string => {...}; I'll see if I can write a plugin to temporarily fix that issue for us. |
Fantastic, thanks! I've run through the gist and fixed the incorrect Next, I'll take a look at the destructuring (+ comments) in this format: const createAlarm = (
{
active = true,
time = '',
repeat = [],
}: {
/** The alarm active state */
active?: boolean | Switch,
/** The alarm time */
time?: string,
/** Whether the alarm should repeat on certain days */
repeat?: Frequency[],
},
): string => {...}; |
Modified destructuring is in, as are the name changes @xAlien95. |
Great, glad it helped 😄
When the .shortcut to .js converter will be ready, I’ll edit each file and look for errors, so no problem. Each action will probably have a direct and inverse function:
|
Currently, TypeDoc is not able to get default values for action parameters and a small refactoring of either the comment bits or the functions themselves has to be done in order to parse them.
I came up with the following solution:
BEFORE
AFTER
Alternatively, JSDoc-ish
@default
tags could be applied on the options type:@joshfarrant, your thoughts? Personally, I prefer the first approach for both the fact that it's more compact and it resembles how actions without parameters are currently written:
I'm open to suggestions and different approaches.
The text was updated successfully, but these errors were encountered: