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

Support automatic inclusion of files using ** (e.g. reference/**) #58

Merged
merged 2 commits into from
Jun 14, 2017

Conversation

GeertvanHorrik
Copy link
Contributor

Fixes #48

Usage is fairly simple (in DocNet):

"Pages" : 
    {
		"Introduction" :
		{
			"Introduction" : "introduction/introduction.md"
                },
		"FAQ" : 
		{
			"General" : "faq/general.md",
			"MVVM" : "faq/mvvm.md",
			"Problem solving" : "faq/problem-solving.md",
			"Performance considerations" : "faq/performance-considerations.md",
		},
                "API reference" : "reference/**"
    }

The API reference part uses the ** at the end. It means that all (sub)folders inside /reference will be checked for MD files. A few automatic rules:

  1. Auto index files will always be generated
  2. The title of the md files will be retrieved from the actual MD files (so the first non-empty line will be used as title)

This becomes extremely useful when parts of the docs are generated via a tool such as SharpDox.

@FransBouma
Copy link
Owner

Could you write a couple of documentation lines to the docs in the gh-pages branch? Thanks :)

@GeertvanHorrik
Copy link
Contributor Author

See #60

@FransBouma
Copy link
Owner

Due to the tabs vs. spaces whitespacing (code used tabs, you used spaces) git thinks the whole navigationlevel file has changed, which isn't the case. I can't see properly what has changed in the file to review it. Will try to revert spaces to tabs and then do a diff.

@GeertvanHorrik
Copy link
Contributor Author

Sorry, didn't notice that. Probably the habit of hitting CTRL + K + D when editing lots of stuff in a file. Normally I try to accept the coding standard of the original project.

Copy link
Owner

@FransBouma FransBouma left a comment

Choose a reason for hiding this comment

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

Can you make the changes to this file? I'll then merge it. If tabs/spaces are a problem, leave them as spaces, I'll correct it here. You don't have to remove the spaces around the () in while/if statements.

Thanks!

public bool IsRoot { get; set; }
#endregion
}
public class NavigationLevel : NavigationElement<List<INavigationElement>>
Copy link
Owner

Choose a reason for hiding this comment

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

the whitespace issues make it hard to review the code. I should have added an editor config file but that's not honored in vs2015 anyway, but nevertheless, things are a bit problematic for reviewing. I can convert the spaces back to tabs tho, it's not the work, but to see which lines are changed.

Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, didn't notice that. Probably the habit of hitting CTRL + K + D when editing lots of stuff in a file. Normally I try to accept the coding standard of the original project.

It's ok, notepad++ happily converts spaces to tabs when you ctrl-a -> TAB, SHIFT TAB :) After thatn winmerge was happy to show the differences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to tabs.

}
public class NavigationLevel : NavigationElement<List<INavigationElement>>
{
private readonly string _rootDirectory;
Copy link
Owner

Choose a reason for hiding this comment

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

All my code has private member fields and properties in their own regions so these things are hidden when you're normally coding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


public void Load(JObject dataFromFile)
{
foreach (KeyValuePair<string, JToken> child in dataFromFile)
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick: you introduced spaces in front of '(' for loops/ifs etc. Likely due to reformatting by a rule in Resharper. Code isn't bad due to that, but next time try to avoid these.

Copy link
Owner

Choose a reason for hiding this comment

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

(don't need to change these for merge btw)

var childValue = child.Value.ToObject<string>();

var endsWithWildcards = childValue.EndsWith("**");
if (endsWithWildcards)
Copy link
Owner

Choose a reason for hiding this comment

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

endsWithWildcards is used just once, you can inline the variable in the if, which is preferable.

continue;
}

var relativeFilePath = GetRelativePath(_rootDirectory, mdFile);
Copy link
Owner

Choose a reason for hiding this comment

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

There's a MakeRelativePath in Utils.cs in the Docnet project, please use that one.

return root;
}

private string GetRelativePath(string origin, string fullPath)
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove and use Utils.MakeRelativePath instead

}

private string FindTitleInMdFile(string path)
{
Copy link
Owner

Choose a reason for hiding this comment

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

At first I thought "We have a markdown parser, why use this!?" but it's indeed a catch-22: you can't use the title from the parsed content like I do with the H2's, as the content might not be parsed yet and the name is used in toc parts on pages where the markdown of this page isn't known (yet). It feels like a hack still, but I don't know of a different way to solve it, so let's keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not extremely happy with this one either, but looked like the least-worst solution.

@FransBouma FransBouma merged commit f516b93 into FransBouma:master Jun 14, 2017
@FransBouma
Copy link
Owner

Merged!

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.

2 participants